Unnecessary access log when socket disconnects before sending any bytes
See original GitHub issueDescribe the bug A socket connection request to server will cause following error:
[2021-08-30 10:29:31 +0800] - (sanic.access)[INFO][UNKNOWN]: NONE http:///* 503 666
[2021-08-30 10:29:31 +0800] [6386] [ERROR] Connection lost before response written @ ('127.0.0.1', 36214) <Request: NONE *>
why and how can i prevent that?
Code snippet server.py
from sanic import Sanic
from sanic import text
app = Sanic.get_app("test", force_create=True)
@app.get("/")
async def response(request):
return text("ok")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=9000, access_log=True, debug=True)
client.py
import socket
if __name__ == '__main__':
server_addr = ('localhost', 9000)
tcp_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcp_socket.connect(server_addr)
tcp_socket.close()
Expected behavior no error msg
Environment (please complete the following information):
- OS: CentOS
- Version: 21.6.2
Issue Analytics
- State:
- Created 2 years ago
- Comments:14 (10 by maintainers)
Top Results From Across the Web
Python Tcp disconnect detection - Stack Overflow
I have a simpletcp example: import socket import time TCP_IP = '127.0.
Read more >Question on Socket disconnect handling - Google Groups
I have modified my code to first call Shutdown and wait for zero bytes to be got before calling socket.close. I have a...
Read more >An Advanced Socket Communication Tutorial
An important characteristic of a datagram socket is that record boundaries in data are preserved. Datagram sockets closely model the facilities found in...
Read more >Analyzing Disconnects - server - Photon Engine
This is the first check you need to do. All clients have some callback to provide log messages about internal state changes and...
Read more >26. WebSocket Support - Spring
This part of the reference documentation covers Spring Framework's support for WebSocket-style messaging in web applications including use of STOMP as an ...
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
I just tested it on version 21.12 and it seems to get fixed.
I disagree. A connection is opened, it should be logged. The level at which that happens I do not disagree is probably not an ERROR. But it shouldn’t be quiet either. If for no other reason, it would be very hard to impossible to track what was happening if you had some rogue agent opening and closing connections in rapid succession.