the unix listener closes the connection unexpectedly with: echo foo | nc -U /tmp/mysock
See original GitHub issueI tried the following example on the AnyIO documentation:
from anyio import create_unix_listener, run
async def handle(client):
async with client:
name = await client.receive(4) # I changed the value
await client.send(b'Hello, %s\n' % name)
async def main():
listener = await create_unix_listener('/tmp/mysock')
await listener.serve(handle)
run(main)
When sending a string with echo foo | nc -U /tmp/mysock
the answer is never printed. However running nc -U /tmp/mysock
interactively it is working.
Also this callback works as expected with asyncio.start_unix_server()
:
async def _handle_request(self, reader, writer):
line = await reader.readline()
writer.write(line)
await writer.drain()
writer.write_eof()
writer.close()
Issue Analytics
- State:
- Created 3 years ago
- Comments:11 (10 by maintainers)
Top Results From Across the Web
netcat: send text to echo service, read reply then exit
The problem is that nc will close the connection immediately after stdin is closed, which is very quick for a simple my_command string,...
Read more >psql: server closed the connection unexepectedly
If the connection aborts randomly I'd suspect network issues. Again, what does the log on the PostgreSQL server say about these terminated ...
Read more >How to automatically close netcat connection after data is sent?
I am executing the following command from a script: echo '{"hostUp": true}' | sudo ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I figured it out. There’s something I didn’t know – you have to return
True
from a Protocol’seof_received()
method, or else the transport will be shut down.Fixed via 3b4c6495, released in v2.2.0.