<div dir="auto">Yes, I used ChatGPT to seed my Twisted client server samples. The problem is integrating Twisted with a loop oriented part of my app. I tried to have ChatGPT generate the whole app.</div><div dir="auto"><br></div><div dir="auto">Twisted is excellent, but may still not work. I don’t want to queue up data waiting for a client, but perhaps I can update the client when it connects.</div><div dir="auto"><br></div><div dir="auto">John </div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Aug 15, 2023 at 2:28 PM Jonathan Duncan <<a href="mailto:jonathandouglasduncan@gmail.com">jonathandouglasduncan@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<p>Hey John, <br>
I put your message through ChatGTP-4. Just in case any of this
helps with your project.<br>
<br>
Your project sounds very interesting, and you've done a lot of
work on it already. SWML is a Sport Movement Standard that is used
to describe and analyze sports movements. Even though it isn't
directly related to your use case (streaming Humanoid
information), the principles used in its design could be helpful
to consider.<br>
<br>
In your Python script, you're running into a problem with repeated
TCP socket connections in a loop. The error you're getting usually
suggests that the other end of the socket (in your case, the
server) is prematurely closing the connection. <br>
<br>
There are a couple of potential issues and solutions:<br>
<br>
1. Server Side: Ensure your server script handles multiple
connections efficiently. Perhaps the server limits the number of
open connections at a time and drops others. <br>
<br>
2. Client Side: TCP connections often have a short time delay (a
few seconds) before fully closing, to ensure that all data gets
through. Rapidly opening and closing connections could exhaust
your available "ephemeral ports" and cause connection issues. If
possible, try opening one persistent connection and sending all
your data down this.<br>
<br>
3. Data Send: Always ensure data is sent completely. Using
`sendall()` instead of `send()` is a good practice as it continues
to send data from the string until either all data has been sent
or an error occurs.<br>
<br>
Regarding streaming in Python, many people use Python libraries
like Flask or Django to create streams, so you may find these
helpful. Popular libraries for socket programming include
`socketio`, `websockets`, `aiohttp` etc.<br>
<br>
Also, for networking issues, you may want to consider using
"Wireshark" or any other network protocol analyzer tool. This will
help you know what's happening at the network layer. <br>
<br>
As for the future language for your project, JavaScript could be a
good choice. It is widely used for both front-end and back-end
development (Node.js), and has good support for sockets and
streaming data (via libraries like `<a href="http://socket.io" target="_blank">socket.io</a>`).<br>
<br>
Keep in mind, moving away from Python, you'll need to handle
connecting to MediaPipe in a different way. MediaPipe provides
precompiled libraries and wrappers for multiple languages
including Python, C++, and Java. For languages other than these,
consider running MediaPipe in a Docker container and connect to it
with your preferred language. <br>
<br>
Finally, do remember that networking and sockets can be tricky.
Issues can stem from firewall rules, operating system settings,
hardware limitations and much more. Debug systematically, change
one thing at a time, and you'll nail down the problem. You're
definitely on the right path - keep going!<br>
</p>
<div>On 8/14/2023 4:22 PM, John Carlson
wrote:<br>
</div>
<blockquote type="cite">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<div style="display:inline">Subject: </div>
Re: [Sw-l] SignTube Program for SW captions on videos</td>
</tr>
<tr>
<td>
<div style="display:inline">From: </div>
John Carlson <a href="mailto:yottzumm@gmail.com" target="_blank"><yottzumm@gmail.com></a></td>
</tr>
<tr>
<td>
<div style="display:inline">Date: </div>
8/14/2023, 4:22 PM</td>
</tr>
</tbody>
</table>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td>
<div style="display:inline">To: </div>
Ronnie Fagundes de Brito <a href="mailto:ronniefbrito@gmail.com" target="_blank"><ronniefbrito@gmail.com></a></td>
</tr>
<tr>
<td>
<div style="display:inline">CC: </div>
Jonathan Duncan <a href="mailto:jonathandouglasduncan@gmail.com" target="_blank"><jonathandouglasduncan@gmail.com></a>,
SignWriting List <a href="mailto:sw-l@listserv.linguistlist.org" target="_blank"><sw-l@listserv.linguistlist.org></a></td>
</tr>
</tbody>
</table></blockquote></div><div><blockquote type="cite">
<br>
<div lang="x-unicode">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">
<div dir="ltr">I'd like to hear more about SWML as I am
creating a new streaming format (which is currently
unnamed, but a previous version had the extension .rg
for route graph, before that I was using serialized
Java) for recording and processing Humanoid information
from MediaPipe. I'm having trouble with networking using
Python, so I haven't done much streaming yet, apparently
default sockets on python require many connections, so I
might not be able to do streaming unless I find a
better socket library. I've tried turning off my
firewall, added exclusions to antivirus, and used a
virtual environment that was excluded from antivirus. I
get like a page or two of data in the terminal on the
server log, and I get: "ConnectionAbortedError:
[WinError 10053] An established connection was aborted
by the software in your host machine." I'm on Windows
10.</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">My format approach is to do something like
BVH (Biovision Hierarchy), but a graph instead of a
hierarchy (with From/To links for bones between two
joints), but I think I will be able to remove things
from the "skeleton graph," which is an important feature
of my streaming format. I'm streaming with python that
generates data from Google MediaPipe's Holistic. I
haven't moved on from this to the MediaPipe's new tasks
structure, but I might if I can get x,y,z coordinates,
even if I can't see the skeleton on the video. At least
I'll have video (with opencv). But I'm moving away from
Python, probably to JavaScript. I don't see Java being
taken seriously by MediaPipe. Android/Kotlin, yes--I
guess I could learn Kotlin.
<div><br>
</div>
<div>I would like to prove a client/server approach so I
can separate the skeleton geometry stream generation
from the rest of the system. I realize that saving
the stream to a file is an important first step, but
if I can't get networking working on my local system,
I might use bash piping to go from one tool to the
next, or save to a file (yuck!). Using a pipe is more
private, but fewer features than networking.</div>
<div><br>
</div>
<div>Here's a Python program loop that has multiple
connections (couldn't do one), that actually *doesn't*
work, Apparently, one's data needs to be extremely
short. It varies between the last string being
"CHICKEN," "CROW," and "EOF." I guess it's time to do
the stackoverflow thing, if not Copilot.</div>
<div><br>
</div>
<div>
<div>import socket</div>
<div><br>
</div>
<div><br>
</div>
<div>sock = None</div>
<div><br>
</div>
<div>def msgSend(sock, data):</div>
<div> if data:</div>
<div> sock.send((data).encode())</div>
<div><br>
</div>
<div>def socketCreate():</div>
<div> HOST, PORT = "localhost", 3000</div>
<div> sock = socket.socket(socket.AF_INET,
socket.SOCK_STREAM);</div>
<div> sock.connect((HOST, PORT))</div>
<div> return sock</div>
<div><br>
</div>
<div><br>
</div>
<div># Create a socket (SOCK_STREAM means a TCP
socket)</div>
<div>if __name__ == '__main__':</div>
<div> for i in range(1,2001):</div>
<div> print(f"Connection {i}:");</div>
<div> sock = socketCreate()</div>
<div> msgSend(sock, "DUCK\n")</div>
<div> msgSend(sock, "GOOSE\n")</div>
<div> msgSend(sock, "RAVEN\n")</div>
<div> msgSend(sock, "EAGLE\n")</div>
<div> msgSend(sock, "CHICKEN\n")</div>
<div> msgSend(sock, "CROW\n")</div>
<div> sock.sendall("EOF\n".encode())</div>
<div> sock.shutdown(socket.SHUT_RDWR)</div>
<div> sock.close()</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote></div><div><blockquote type="cite"></blockquote>
</div>
_______________________________________________<br>
Sw-l mailing list<br>
<a href="mailto:Sw-l@listserv.linguistlist.org" target="_blank">Sw-l@listserv.linguistlist.org</a><br>
<a href="https://listserv.linguistlist.org/cgi-bin/mailman/listinfo/sw-l" rel="noreferrer" target="_blank">https://listserv.linguistlist.org/cgi-bin/mailman/listinfo/sw-l</a><br>
</blockquote></div></div>