d-vova / vs-stun

STUN protocol implementation in NodeJS
MIT License
24 stars 11 forks source link

problem when OTHER-ADDRESS is specified but times out #1

Open bprodoehl opened 10 years ago

bprodoehl commented 10 years ago

I love this library, but it is failing against the Coturn server (https://code.google.com/p/coturn/). Coturn is returning the OTHER-ADDRESS attribute in its initial response, which puts vs-stun into trying to map to OTHER-ADDRESS.

OTHER-ADDRESS in this case usually has a different port, but vs-stun sends its request to the new address but the old port. I don't know the STUN RFC inside and out, but I'm guessing that this line may be a bug:

var otser = { host: other.host, port: server.port }

In the normal case, the initial request and response are on port 3478, and the OTHER-ADDRESS is the same address but port 3479. The second request goes out to port 3478, and the second reply comes back from 3479, which will then get dropped or rejected by normal firewall rules. This causes vs-stun to timeout, saying that UDP is blocked, even though the initial binding response was fine.

bprodoehl commented 10 years ago

I think the relevant bit is here: http://tools.ietf.org/html/rfc5780#page-14

So vs-stun is correctly doing the second phase of the test, sending a binding request to other.host and server.port. I guess it doesn't make sense to move on to the third test if that second test times out, but it would be nice to return something nicer than UDP blocked if the initial response did actually come in.