Hi All,
I am trying to build a simple SockJS to TCP(SSL) proxy server by embedding vertx core into a Java application. below is what I am trying to accomplish
1. The application will host a SockJS server on one end to which Java Script clients using SockJS will connect.
2. For each connection to SockJS server, the application will create a corresponding SSL TCP connection to another SSL TCP server using NetClient. This is like a one to one connection through the proxy.
3. The client will send some base 64 encoded binary data through the SockJS socket. The proxy server application will base64 decode the data into a binary byte array and send to the TCP server via the corresponding NetClient socket. Similarly, if TCP server send any binary data over the NetClient socket, the same needs to be Base64 encoded and sent across the SockJS socket.
4. if the NetSocket breaks for any reason, the corresponding SockJS socket should be closed by the application and similarly, if the sockJS socket is cut/closed, the NetSocket connection should be closed.
5. The app has to scale to handle at least 40k connections. (i.e 40k in coming SockJS connections and 40k outgoing NetSocket connections, but the higher the better. The hardware for this will include a hex core CPU along with 12GB RAM.
I have built a similar proxy server using node.js and
socket.io (scaling not tested at all), but want to do it using vert.x and make it scalable. Note that running the standard vert.x container application with vertices is not an option as I need to build a custom application using just vert.x as library. I can create vertices, but they have to be launched from my custom application only.
Any help, guidance would be appreciated as I am new to both Java and vert.x.
So far, I have made a sample project in which I put the required dependencies created a vertx object and from that a SockJS server. I have some code written to create the NetSocket connection to the TCP server when ever there is a incoming connection on SockJS. The next part is how to handle the data. I need to do a base64 encoding/decoding step before putting the data on to the counterpart connection.
I understand that if both the sockets carry compatible data formats, I can just create Pumps to handle the data, but in this case, I have do a intermediate step. so how best to do that without running to buffer issues and without blocking other connections.
The next question is how to scale the server to handle a lot of connections?