Networking through proxy server

I’m trying to build a sort of a VPN System. So that I can have people host their own games, have the hosting client connect to the central server, and have the server act as a sort of proxy between other clients and the hosting client, so that people don’t have to forward their ports in order to host a game. Is this possible with the jme3 network server? Is it possible to run the jme3 connection through a Socket?

JME is already using sockets for its connections. So I don’t understand that part of the question.

As to the other, it depends on how you are proxying. Sounds like it would add a lot of lag, though.

Post isn’t so clear.Will server be hosted in the same machine of the hosting client?

Let me re phrase that question. Is it possable for two Clients to connect to a Server in JME3, and have the server pass data from one client to the other, Tricking on client into treating the other client like the server? If so, how?

Depends on how your game-specific code is written.

…because generally if you want to run a server on a client then you’d just start a server.

Having to relay all messages through a third party is going to greatly slow the game down as all traffic will take more than twice as long to travel. Maybe it’s ok for a turn based game but then the answer to your question is easy because your network architecture gets really simple in that case. Just forward the received messages to the right code on wherever you want the ‘server’ to be.

Hard to answer more specifically given the little information provided. But really I suspect you should be looking for a lower level solution, perhaps.

If your goal is being able to use p2p connections without asking the player to configure nat and firewall in order to be able to host the server, you can use nat hole punching with both tcp and udp, but that is not something you can do with spidermonkey i guess.

udp hole punching can easily be done with java.
Just throw a bunch of udp packes from both clients each way (you know the other sides address and can determine a port for both using the central server)

After this attempt to let spidermonkey connect.

Also keep a fallback in mind if this does not work.
Also show the player the required port, if only one forwards this greatly increases the chance to at least get a backup tcp link to work.

“Tricking on client into treating the other client like the server? If so, how?”

I don’t think you can without modifyng spidermonkey,

Just to clarify:
spidermonkey uses tcp for reliable connections, so you need tcp hole punching too, and regarding udp hole punching some routers remove the nat rule immediately after you receive a packet from the address, so you should reply with a keep alive packet each time your receive an udp packet.

Sure, that what I said,

udp hole punching is great, but always be prepared for it to not work. Thats why I mentiond fallbacks, using a central server as a proxy is such a thing however. For anything not a shooter/platformer it might work fine enough.

(reason why i have a tcp backup connection n my game, better with slight lags than nothing :smile: ))