Photon networking stops randomly when using TCPClient

I’m using to receive 160.8 Kbps of data, and after a few seconds, all network traffic (TCPClient and cloud) stops. The Photon hasn’t hung though, it’s most definitely still running as I’ve checked using the serial port.

Here’s the code if it helps. I know it’s a bit messy but that’s just due to laziness.

@Techjar, the title says Photon but then you say “The core hasn’t hung…”. Is this code running on a Core or a Photon?

@peekay123 Oops, my bad. It is in fact a Photon. I will correct that error.

I am still having this issue with the latest firmware (0.4.7 at the time of writing this), has this been looked into at all?

If you can produce a minimal app that illustrates the problem, that will help us investigate the issue. Thanks! :slight_smile:

@mdma, in the first post of this thread there is a “minimal” app linked.
I think it’s safe to ignore the SPI and have MOSI open.

@ScruffR, Yes, the SPI is just sending data to the other hardware I’m driving, and never receives anything, so it should not make a difference whether or not that is physically connected to anything.

I’m afraid that code is far from minimal - I’m not even sure what server to connect it to. What I’m looking for is the minimum amount of code that shows the problem, ideally running against a public server.

The code for the Photon is in the original post, though you’ll probably want this Java application too as it runs the TCP server which the Photon connects to. You’ll need to edit the Photon code and change the IP to match whatever it needs to be on your local network.

Photon code:
Java app:

Edit: Probably should add that the application won’t run on a headless system, as it needs a GPU.

@Techjar, I was unable to test your “minimal” application against the Java application you provided since it doesn’t include any dependency jars.

However, I wrote a simple tcp server in python which should probably do the same thing and tested the application against that.

import socket
import time
import struct

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)


snddata = struct.pack('>BL', 0, 330)
snddata += '\0' * 330

while True:
    conn, addr = s.accept()
    print 'Connected ', addr
    pak = conn.recv(5)
    print 'Received capabilities packet ', pak
    while True:
        print 'Sending ', len(snddata)
        print snddata.encode('hex')

Unfortunately, I couldn’t reproduce the issue you are having. Could you provide a minimal example that reliably showcases the issue and maybe run your server on a public IP address?

@avtolstoy I think you are due a “Hats Off” award for support beyond the call of duty. I assume that the TCPClient worked fine for you.

@avtolstoy, Oh, oops, I do seem to have forgotten to include the lib directory. Download this version, and just combine its “lib” with the files from the other zip, as this is a slightly different version that’s not designed for use with that Photon code. My internet is rather slow so I don’t want to upload all the lib jars again. That’s also why I can’t just host this for you from my home network.

If you can’t get that working, I can try to cobble together something that implements the protocol and runs headless, then toss it on my dedicated server.