OS 2.7.2: Playdate stops receiving data via TCP

Hi,

first off, I love the Playdate and the addition of the new networking APIs β€” it's really fun developing on it.

While working on a small online game (in C), I encountered the issue that the Playdate stops receiving data from a server I'm connected to via a TCP socket after running for a short time, and eventually crashes. The same setup works fine in the Simulator.

To reproduce, I built a simple test app:

  • The Playdate sends a newline-terminated "PING" message to a TCP server ~10 times per second
  • The server responds with "PONG" each time.
  • Everything works great for a while, then the Playdate stops receiving any data but still sends out "PING" messages
  • Eventually, the connection stalls and crashes the app.

I used Wireshark to debug the TCP stream (please see the attached screenshot, the server is on port 24567), I observed the following:

The server occasionally retransmits a packet with the same TCP sequence number and same payload length (Seq=940).

After this retransmission, the Playdate only acknowledges the data that was sent before (in this case the first 940 Bytes)

The server continues (re-)transmitting until it eventually resets the connection.

The Playdate does not appear to detect the reset β€” the SDK callback for a closed connection isn't triggered β€” and keeps sending "PING" messages until the write operation stalls and the app crashes.

I tried various mitigations like reducing the message frequency, enabling/disabling Nagle’s algorithm, and inserting delays β€” they delay the issue but don’t prevent it. Although in the real game I don't have nearly that frequency that I have in my test app.

I'm not an expert for the TCP protocol by any means, but it seems to me, that there might be a problem in the implementation of the stack that occurs when packages are resent or composed.

Note: This issue does not occur in the (Windows) Simulator β€” only on actual hardware.

Please let me know if I can provide any additional information.

Thanks again for the amazing platform, I hope this helps

We'll have 2.7.3 with a lot of fixes for networking out soon. Let's see how that goes and I'll take a closer look at this if we're still having problems. :crossed_fingers:

1 Like

Thanks, looking forward to the update.

1 Like

I am still having the same issue on 2.7.3

Windows SDK Lua and testing on a PD device.

When reading and sending repeatedly using TCP to a local server, the PD will stop sending and receiving entirely after it becomes what I could only explain as "overwhelmed". First, receiving turns off, and sending becomes sporadic. But then it stops completely and sometimes (especially in a real game scenario) crashes and says "Run loop stalled for more than 10 seconds pc=0x24003F0B4 lr=0x24030C8B" But the getError() returns nil the whole time, indicating no error.

The above post has a lot of great detail, but I want to confirm that it also happens to me.

This is my small test program that can reproduce the issue.
main.lua to reporduce TCP error.zip (865 Bytes)
(You will need to change your IP and port.)

Interestingly, in a real game that takes up some resources when you start calling read() and write(), the "idle" jumps in size even when it should not, and the game is seriously struggling for resources.

Let me know if you need anything else!

thank you so much for the demo! I'll get this sorted out asap and we'll try and get 2.7.4 out next week

1 Like