Messages sent are received "one behind" when using WSS.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- networking
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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())
- Lenguaje dominante
- Python
- Estrellas
- 1.1k
- Forks
- 284
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Lawouach/WebSocket-for-Python
-
Dificultad 3/5 1-2 días Aptitud para principiantes 45/100
Lawouach/WebSocket-for-Python#300 ·
-
This project is not well maintained so be very very very patient!Quizá libre de nuevo @Lawouach la tomó hace 663 días y no hay ningún pull request abierto. Abiertoquestion
Lawouach/WebSocket-for-Python#297 · 2 comentarios · 1 asignado ·
-
Dificultad 4/5 3-5 días Aptitud para principiantes 20/100
Lawouach/WebSocket-for-Python#296 ·
-
Make the codes python 3 compatibleQuizá libre de nuevo @auvipy la tomó hace 1070 días y no hay ningún pull request abierto. Abierto
Lawouach/WebSocket-for-Python#280 · 1 comentario · 1 asignado ·
-
Setup new CIQuizá libre de nuevo @auvipy la tomó hace 1241 días y no hay ningún pull request abierto. Abierto
Lawouach/WebSocket-for-Python#275 · 1 asignado ·
Todos los issues de Lawouach/WebSocket-for-Python
Issues similares
-
[Bug]: Streamed /v1/chat/completions sends unredacted agent error text (keys) in the final chunkPosiblemente ocupada @rodricksz4h5 la tomó hoy. Abiertoarea/streaming comp/gateway P2 type/security
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
NousResearch/hermes-agent#138245 ·
Los mantenedores suelen responder en 1 día
-
[oblt-aw][autodoc] Update user onboarding guide for mandatory trigger CODEOWNERS stepPosiblemente ocupada @github-actions la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día
-
correction metadata
Dificultad 2/5 Menos de una hora Aptitud para principiantes 68/100
acl-org/acl-anthology#10378 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
cloudtrail_multi_region_enabled_logging_management_events fails when the advanced event selector has a custom namePosiblemente ocupada @12YYCCYY16 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
prowler-cloud/prowler#13033 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
graygarbage/HermesKey#23 ·