Messages sent are received "one behind" when using WSS.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Bug
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- python
- Ambito
- networking
Direzione di ricerca
Reproduce the behavior using test.py and test.html with both ws:// and wss://, comparing the logged received_message output and browser responses. Trace the WSS receive path first and identify why messages lag by one; done means consecutive client messages are received and echoed immediately in WSS mode as they are in WS mode.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
ws4py==0.5.1
CherryPy==18.6.0
Python 3.9.5 / Mac OS 11.4 (M1)
Messages are received as expected when I use WS. If I switch to WSS, messages sent by the client/browser are not received by the server until after a subsequent message is sent by the client (which in turn is also delayed). Once the second message is sent, the first message is received.
I note issue https://github.com/Lawouach/WebSocket-for-Python/issues/191 which appears to be similar.
Output from attached test client and server:
WS mode
Chrome console:
on open
sent: one
sent: two
sent: three
Message received:one back
Message received:two back
Message received:three back
Python output:
2021-07-04 19:46:11,986:INFO: Using select as epoll is not available
2021-07-04 19:46:11,986:INFO: [04/Jul/2021:19:46:11] ENGINE Listening for SIGTERM.
2021-07-04 19:46:11,986:INFO: [04/Jul/2021:19:46:11] ENGINE Listening for SIGHUP.
2021-07-04 19:46:11,986:INFO: [04/Jul/2021:19:46:11] ENGINE Listening for SIGUSR1.
2021-07-04 19:46:11,986:INFO: [04/Jul/2021:19:46:11] ENGINE Bus STARTING
2021-07-04 19:46:11,986:INFO: [04/Jul/2021:19:46:11] ENGINE Starting WebSocket processing
2021-07-04 19:46:11,986:INFO: [04/Jul/2021:19:46:11] ENGINE Started monitor thread 'Autoreloader'.
2021-07-04 19:46:12,089:INFO: [04/Jul/2021:19:46:12] ENGINE Serving on http://127.0.0.1:9000
2021-07-04 19:46:12,090:INFO: [04/Jul/2021:19:46:12] ENGINE Bus STARTED
2021-07-04 19:46:24,695:INFO: in /test
2021-07-04 19:46:24,696:INFO: 127.0.0.1 - - [04/Jul/2021:19:46:24] "GET /test HTTP/1.1" 101 - "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
2021-07-04 19:46:24,696:INFO: Managing websocket [Local => 127.0.0.1:9000 | Remote => 127.0.0.1:61575]
2021-07-04 19:46:24,935:INFO: received_message:one
2021-07-04 19:46:24,936:INFO: received_message:two
2021-07-04 19:46:24,937:INFO: received_message:three
WSS mode
Chrome console:
on open
sent: one
sent: two
sent: three
Message received:one back
Message received:two back
Python output:
2021-07-04 19:49:39,967:INFO: Using select as epoll is not available
2021-07-04 19:49:39,967:INFO: [04/Jul/2021:19:49:39] ENGINE Listening for SIGTERM.
2021-07-04 19:49:39,967:INFO: [04/Jul/2021:19:49:39] ENGINE Listening for SIGHUP.
2021-07-04 19:49:39,967:INFO: [04/Jul/2021:19:49:39] ENGINE Listening for SIGUSR1.
2021-07-04 19:49:39,967:INFO: [04/Jul/2021:19:49:39] ENGINE Bus STARTING
2021-07-04 19:49:39,967:INFO: [04/Jul/2021:19:49:39] ENGINE Starting WebSocket processing
2021-07-04 19:49:39,967:INFO: [04/Jul/2021:19:49:39] ENGINE Started monitor thread 'Autoreloader'.
2021-07-04 19:49:40,073:INFO: [04/Jul/2021:19:49:40] ENGINE Serving on https://127.0.0.1:9000
2021-07-04 19:49:40,073:INFO: [04/Jul/2021:19:49:40] ENGINE Bus STARTED
2021-07-04 19:49:56,428:INFO: in /test
2021-07-04 19:49:56,429:INFO: 127.0.0.1 - - [04/Jul/2021:19:49:56] "GET /test HTTP/1.1" 101 - "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36"
2021-07-04 19:49:56,430:INFO: Managing websocket [Local => 127.0.0.1:9000 | Remote => 127.0.0.1:62492]
2021-07-04 19:49:56,641:INFO: received_message:one
2021-07-04 19:49:56,642:INFO: received_message:two
test.html
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript">
function webSocketTest() {
if ("WebSocket" in window) {
var socket = new WebSocket("wss://local.example.com:9000/test");
//var socket = new WebSocket("ws://local.example.com:9000/test");
function send(text) {
socket.send(text)
console.log(`sent: ${text}`)
}
socket.onopen = function () {
console.log("on open")
send("one");
send("two");
send("three");
};
socket.onmessage = function (event) {
var received = event.data;
console.log(`Message received: ${received}`);
};
}
else {
console.log("No WebSocket support");
}
}
</script>
</head>
<body>
<div>
<input id="run" type="button" value="Upgrade" onclick="webSocketTest();" />
</div>
</body>
</html>
test.py
#!/usr/bin/env python3
import sys
import logging
import cherrypy
from ws4py.server.cherrypyserver import WebSocketPlugin, WebSocketTool
from ws4py.websocket import WebSocket
class TestWebSocket(WebSocket):
def received_message(self, message):
message = message.data.decode('utf8')
logging.info("received_message:%s", message)
self.send(f"{message} back")
class Root:
@cherrypy.expose
def test(self):
logging.info("in /test")
def main():
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s:%(levelname)s: %(message)s")
config = {
"global": {
"server.ssl_module": "builtin",
"server.ssl_certificate": "/etc/ssl/certs/STAR_example_com.chain.pem",
"server.ssl_private_key": "/etc/ssl/private/STAR_example_com.key",
"server.socket_port": 9000,
"log.screen": False,
},
"/test": {
"tools.websocket.on": True,
"tools.websocket.handler_cls": TestWebSocket,
}
}
WebSocketPlugin(cherrypy.engine).subscribe()
cherrypy.tools.websocket = WebSocketTool()
cherrypy.quickstart(Root(), "/", config=config)
if __name__ == "__main__":
sys.exit(main())
- Lingua principale
- Python
- Stelle
- 1.1k
- Fork
- 284
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Lawouach/WebSocket-for-Python
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
Lawouach/WebSocket-for-Python#300 ·
-
This project is not well maintained so be very very very patient!Forse di nuovo libera @Lawouach l’ha presa 662 giorni fa e non c’è nessuna pull request aperta. Apertaquestion
Lawouach/WebSocket-for-Python#297 · 2 commenti · 1 assegnatario ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Make the codes python 3 compatibleForse di nuovo libera @auvipy l’ha presa 1068 giorni fa e non c’è nessuna pull request aperta. Aperta
Lawouach/WebSocket-for-Python#280 · 1 commento · 1 assegnatario ·
-
Setup new CIForse di nuovo libera @auvipy l’ha presa 1240 giorni fa e non c’è nessuna pull request aperta. Aperta
Lawouach/WebSocket-for-Python#275 · 1 assegnatario ·
Tutte le issue di Lawouach/WebSocket-for-Python
Issue simili
-
Consolidate the now-identical CLI-native and composed tasks_packages guards (#5945 follow-up)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
spec-kitty/spec-kitty#6112 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: OpenRouter streaming chunks report the requested router name instead of the model OpenRouter servedForse già presa @Mrun25 l’ha presa oggi. Apertabug llm translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BerriAI/litellm#46095 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
uberdeveloper/fastbt#29 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
andrew-blake/melcloudhome#368 ·
I maintainer di solito rispondono entro 1 giorno
-
lane:discover
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SPARDiffData/differential-data-collection#33 ·
I maintainer di solito rispondono entro 1 giorno