Combine Jetty and vert.x - jetty

I am working on a central headless service, based on Equinox, that should support plug-ins to contribute web functionality. The head is to manage the main entry point for web requests (that is the HttpServer on port 80 and 443) and yet I would like to leave the plug-ins to use their own communication technologies.
One case I have here is vert.x so the scenario is that I initially take the connection from Jetty and then, if the url leads to the resp. plugin, pass it to the vert.x instance.
So. e.g. a call to http://example.org/vertxplugin leads to the inital http://example.org accepted by Jetty which then identifies the vertxplugin as target passing the resp. connection.
Currently I do not see how such a scenario can be realized - as I see only examples of vert.x generating the HttpServer or jetty generating the HttpServer.
Additionally is something like
// create the websocket
vertx.createSockJSServer(httpServer).bridge(config, inOK, outOK);
where the httpServer mentioned here is Jetty, possible??
Thanks for any hints.

Related

Qt+wasm client-server communication

In Qt webassembly documentation there is a mention, than one can use QNetworkAccessManager for HTTP communication with the server that hosts my website. The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
The problem is, that I can't hard-code URL for the server as it should be able to be deployed on any server. Is there a simple way to receive it somehow?
Yes. Your server program runs a QApplication, and the single instance of that class could get that URL.
In other words, you'll document that your C++ program (the executable file obtained by compilation, e.g. with GCC) foo would accept some --server-url argument, and you would start foo --server-url http://example.com/somestrangeurl/
Please notice that WebAssembly is often running inside Web browsers (that is, inside Web or HTTP clients). Most HTTP servers (e.g. lighttpd) are running on Linux OS (and you might use Wt or libonion or some other HTTP server library for them, if you have to code your HTTP server from scratch).

How to make Qt Websocket and QNetworkRequest (HTTP) to use the same connection?

Is it possible with Qt to upgrade a HTTP connection that handles the normal HTTP requests to a Websocket with the same connection?
I'm thinking about something like this with Poco libraries, but all done in Qt similar to QtWebApp.
The simple answer is no and that is mostly because of specifics of the server side. And Qt just follows the protocol available and exposed by the server (HTTP/WebSocket) as mostly the client-side development framework and AFAIK won't be able to do the kind of transformation you want of going from HTTP to Websocket that are two different protocols. But of course, theoretically that can be done as long as both protocols able to use IP port 80. But that implies new unique sever and new unique client implementations.
We use both WebSocket and REST in our app. And WebSocket is for triggering the client by the server to do something. Client gets the "poke" from the server and starts normal JSON HTTP-based exchange with the server.
Somewhat relative link: https://softwareengineering.stackexchange.com/questions/276253/mixing-rest-and-websocket-in-the-same-api

What is the right approach in using Thrift in invoking webservice on Websphere?

I am writing an app on Thrift and webservice deployed on Websphere. Thrift client will be calling thrift server which inturn make a webservice call to webservice deployed on websphere.
Where will I host Thrift server implementation since it will be standalone app? Can it be started before/on startup of Websphere app server?
Shall I run Thrift as a standalone and then how will Thrift server get the common VOs being shared between Thrift server (which is client to webservice) and server(webservice hosted on Websphere)?
What should be right approach in this case since Thrift will be opening a socket which is making a websphere call even though both servers are collocated?
Is it safe to use sockets as a medium of rmi/rpc instead of http? What will be security loopholes since port will be opened for communication?
Thanks.
Quick reply will be highly appreciated.
Thrift service might be implemented either as a standalone application or as an webapp running on the same app server. In latter case thrift service doesn't have to serve any http requests, it should just start thrift server on app startup/shutdown. The advantage is that you can utilize all appserver infrastructure: lifecycle, monitoring, JMX, etc.
To share VOs between two JVMs, it's usually enough to make them 'implements Serializable' and add classes to both classpaths. Sharing within single JVM is trivial. So, there should be no problems here.
Yes, socket communication is just fine, even if servers are collocated.
Yes, it is safe enough, if configured properly. Restricting access to corresponding ports with firewall is probably the easiest.

How do I bind web service to a particular glassfish port?

I have Glassfish 3.1.1 (Metro JAX-WS stack) installation with several http listeners in my domain's virtual server.
When I deploy my EAR, web application and soap services are all bound to all available http listeners whereas I want them to be held by different listeners, each having it's own performance and connection pool setup.
I believed that sun-web.xml should be responsible for that sort of binding but I haven't found any options of binding service to specific port or virtual server.
Any ideas?
One option is to use the deploy command with an accordingly set virtualservers commandline parameter... for reference see http://download.oracle.com/docs/cd/E18930_01/html/821-2433/deploy-1.html or page 262 etc. at http://download.oracle.com/docs/cd/E18930_01/pdf/821-2433.pdf
Another option:
Several config files have new names (for example glassfish-web.xml is the new name for sun-web.xml).
To bind your EAR to specific URI see esp. the web element and its sub-element like web-uri - for details and samples see
http://download.oracle.com/docs/cd/E18930_01/html/821-2417/beaqk.html#scrolltoc
http://download.oracle.com/docs/cd/E18930_01/html/821-2417/beaql.html
http://javahowto.blogspot.com/2010/10/glassfish-webxml-and-sun-webxml.html

Secure data transfer over http with custom server

I am pretty new to security aspect of application. I have a C++ window service (server) that listens to a particular port for http requests. The http requests can be made via ajax or C# client. Due to some scope change now we have to secure this communication between the clients and custom server written in C++.
Therefore i am looking for options to secure this communication. Can someone help me out with the possible approaches i can take to achieve this.
Thanks
Dpak
Given that you have an existing HTTP server (non-IIS) and you want to implement HTTPS (which is easy to screw up and hard to get right), you have a couple of options:
Rewrite your server as a COM object, and then put together an IIS webservice that calls your COM object to implement the webservice. With this done, you can then configure IIS to provide your webservice via HTTP and HTTPS.
Install a proxy server (Internet Security and Acceleration Server or Apache with mod_proxy) on the same host as your existing server and setup the proxy server to listen via HTTPS and then reverse proxy the requests to your service.
The second option requires little to no changes to your application; the first option is the better long-term architectural move.
Use HTTPS.
A good toolkit for securing your communication channel is OpenSSL.
That said, even with a toolkit, there are plenty of ways to make mistakes when implementing your security layer that can leave your data open to attack. You should consider using an existing https server and having it forward the requests to your server on the loopback channel.
It's reasonably easy to do this using either OpenSSL or Microsoft's SChannel SSPI interface.
How complex it is for you depends on how you've structured your server. If it's a traditional style BSD sockets 'select' type server then it should be fairly straight forward to take the examples from either OpenSSL or SChannel and get something working pretty quickly.
If you're using a more complex server design (async sockets, IOCP, etc) then it's a bit more work as the examples don't tend to show these things. I wrote an article for Windows Developer Magazine back in 2002 which is available here which shows how to use OpenSSL with async sockets and this code can be used to work with overlapped I/O and IOCP based servers if you need to.