Multiplayer through NAT

Hey I am trying to get my game set up so that users can host multiplayer games without having to do port forwarding etc.
I have been reading up about hole punching but cant seem to get it to work.
I set up a introduction server on amazon and both connections can connect to it and use the simple chat server going but when they try to connect to each other it just fails.
it seems that this approach is really only useful using UDP connections, so is there an implement ion of spider monkey or some other networking capabilities that operate solely through UDP?
Has anyone got a java implementation of STUNT to work with spider monkey?

You are right that in its default configuration SpiderMonkey will not support a solely UDP connection. It requires at least one TCP connection.

It’s probably possible to work around this by wiring up the parts yourself but I would say it’s not at all straight forward and may have additional issues. Connection setup, for one, requires that no packets are missed and that they all come in order.

Trying to do any reliable networking over UDP is extremely non-trivial. I recommend avoiding solutions that require UDP-only.

Basically you are required to simulate tcp behaviour over udp if you want to do this, to support reliable (stream based) data transfer.
Once you got this to work, the rest is more simple, as you can just reuse the rest of spidermonkey for the actual message serialisation ect.

Reliable udp is quite doable as you don’t need to create anything completely new, but must exactly copy behaviour (with a ton of implications based on it).
Of course this depends on the targetd performance.

And if you do create a reliable UDP transport then it’s relatively straight forward to plug this into SpiderMonkey.

Have you considered using UPnP to configure the port forwarding on the players router? Maybe this is what you mean by “hole punching”.

I have used “sbbi-upnplib” in my day job for this and it works well. Most consumer routers have the option to enable UPnP, although sensible routers probably won’t enable it by default. I should say this library looks unmaintained now, although I know it still works well. There are plenty of other Java UPnP implementations out there though.

Here is an example of use of the library in a gaming context.

RR

Upnp is a good addition to make udp hole punching more reliable, but I would never expect it to exist/work.

Thanks for the input. I looked into UPnP buy got the feeling that its was only for local networks not external connections, and not available on many systems.
I will look into it further. The upnplib looks like it should be able to set up port forwarding automatically which would be awesome.
The method I was trying to implement comes from this site, but doesn’t go into much detail.
I think setting up low level connections to feed into spidermonkey is a bit beyond me.