Note that there are some explanatory texts on larger screens.

plurals
  1. POpython socketserver occasionally stops sending (and receiving?) messages
    primarykey
    data
    text
    <p>I've been experiencing a problem with a socketserver I wrote where the socketserver will seem to stop sending and receiving data on one of the ports it uses (while the other port continues to handle data just fine). Interestingly, after waiting a minute (or up to an hour or so), the socketserver will start sending and receiving messages again without any observable intervention.</p> <p>I am using the Eventlet socketing framework, python 2.7, everything running on an ubuntu aws instance with external apps opening persistent connections to the socketserver.</p> <p>From some reading I've been doing, it looks like I may not be implementing my socket server correctly. According to <a href="http://docs.python.org/howto/sockets.html" rel="nofollow">http://docs.python.org/howto/sockets.html</a>:</p> <blockquote> <p>fundamental truth of sockets: messages must either be fixed length (yuck), or be delimited > > (shrug), or indicate how long they are (much better), or end by shutting down the connection.</p> </blockquote> <p>I am not entirely sure that I am using a fix length message here (or am I?)</p> <p>This is how I am receiving my data:</p> <pre><code>def socket_handler(sock, socket_type): logg(1,"socket_handler:initializing") while True: recv = sock.recv(1024) if not recv: logg(1,"didn't recieve anything") break if len(recv) &gt; 5: logg(1,"socket handler: %s" % recv ) plug_id, phone_sid, recv_json = parse_json(recv) send = 1 if "success" in recv_json and recv_json["success"] == "true" and socket_type == "plug": send = 0 if send == 1: send_wrapper(sock, message_relayer(recv, socket_type)) else: logg(2, 'socket_handler:Ignoring received input: ' + str(recv) ) logg(1, 'Closing socket handle: [%s]' % str(sock)) sock.shutdown(socket.SHUT_RDWR) sock.close() </code></pre> <p>"sock" is a socket object returned by the listener.accept() function.</p> <p>The socket_handler function is called like so:</p> <pre><code>new_connection, address = listener.accept() ...&lt;code omitted&gt;... pool.spawn_n(socket_handler, new_connection, socket_type) </code></pre> <p>Does my implementation look incorrect to anyone? Am I basically implementing a fixed length conversation protocol? What can I do to help investigate the issue or make my code more robust?</p> <p>Thanks in advance,</p> <p>T</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload