question

DontAsk Games avatar image
DontAsk Games asked

UDP Port unable to connect socket - no data sent or received

Hello,

Our game uses both TCP and UDP for communication (TCP for user actions, UDP for movement). We did this on the same port, but then realized that when we upload a server to PlayFab and choose Process mode, we can't have TCP and UDP on one port - so we split them up into port_tcp and port_udp.

The problem arises when we connect to the server, we receive both ports and connect to them, and user actions work, but movement does not (UDP port). When I change the ports and IP to be localhost to test, everything works fine.

Server starts listening:

tcpListener = new TcpListener(ipAddress, TCPPort);
tcpListener.Start();
tcpListener.BeginAcceptTcpClient(new AsyncCallback(TCPConnectCallback), null);


udpListener = new UdpClient(UDPPort);
udpListener.BeginReceive(UDPReceiveCallback, null);

Clients then connect to both UDP and TCP - everything is fine but movement does not work (UDP), whereas user actions do (TCP).

What could be the problem?

TitleID: 47B2F

Build: DevelopmentV8

multiplayersupportMatchmaking
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ivan Cai avatar image
Ivan Cai answered

After running AcceptTcpClient() successfully, there can be a thread occupation issue. You can set up separate threads for the two listeners to solve this issue. Or, it seems okay to define and initialize the UDP listener first. For your case, I find a related thread that can help you. For server-side development issue, I suggest you go to the correspondingforum for dedicated technical support.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

DontAsk Games avatar image
DontAsk Games answered
@Ivan Cai

We're using asynchronous calls to BeginReceive and BeginAccept, so it doesn't hold up the main thread. This issue still hasn't been solved. @Brendan?

2 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Seth Du avatar image Seth Du ♦ commented ·

Does the client use the ports returned from GetMatch API call?

0 Likes 0 ·
DontAsk Games avatar image DontAsk Games Seth Du ♦ commented ·

Yes, we use the IP and ports returned from GetMatch. Recently I found though that the ports we receive are actually not open...

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.