close() api is not shutting down connection
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- networking
Línea de trabajo
Start with ws4py.client.threadedclient.WebSocketClient, especially close(), received_message(), and run_forever(), using the supplied client example to reproduce the behavior. Check how termination flags affect message delivery and verify that calling close() stops subsequent messages and reaches the closed() callback.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Hi,
I am trying to write a websocket client that listens from a websocket server for some events and dumps them on screen. If the length of message exceeds 250 chars, I wan the connection to close. I have written the following code for it:
import time
from ws4py.client.threadedclient import WebSocketClient
WS_HOST='172.17.0.2:8081'
EVENTS_URL = 'ws://' + WS_HOST + '/events'
FAULTS_URL = 'ws://' + WS_HOST + '/faults'
ALARMS_URL = 'ws://' + WS_HOST + '/alarms'
ECHO_URL = 'ws://echo.websocket.org/'
class SNMPWebSocketClient(WebSocketClient):
def opened(self):
print 'Opened client at {0}'.format(self.url)
def closed(self, code, reason=None):
print "Closed down", code, reason
def received_message(self, m):
print m
print 'Client={0}, server={0}'.format(self.client_terminated, self.server_terminated)
print len(m)
if len(m) >= 272:
print 'Send close signal'
self.close()
print '\n\n'
if __name__ == '__main__':
ws = SNMPWebSocketClient(EVENTS_URL)
try:
ws.connect()
ws.run_forever()
except KeyboardInterrupt:
ws.close(code=1002, reason='kb yay Interrupt')
time.sleep(1)
print 'Kb Interrupt'
But while listening the close never goes through. The client and server flags for terminated shows 'True' but still the client keeps receiving messages. Is there something wrong in my use of close()? Or is this how the websocket client is supposed to work until it is explicitly killed?
Here is the output:
$ python threaded_ws.py
Opened client at ws://172.17.0.2:8081/events
{"Enable":true,"OwnerId":1,"OwnerName":"ASICD","EventName":"PortOperStateDown","Description":"Port Operational State DOWN Event","SrcObjName":"Port","EvtId":2,"TimeStamp":"2017-03-28T14:38:32.881456505Z","SrcObjKey":{"IntfRef":"eth25"},"AdditionalData":null}
Client=False, server=False
258
{"Enable":true,"OwnerId":1,"OwnerName":"ASICD","EventName":"VlanOperStateDown","Description":"Vlan Operational State DOWN Event","SrcObjName":"Vlan","EvtId":4,"TimeStamp":"2017-03-28T14:38:32.882046191Z","SrcObjKey":{"VlanId":3050},"AdditionalData":null}
Client=False, server=False
254
{"Enable":true,"OwnerId":1,"OwnerName":"ASICD","EventName":"IPv4IntfOperStateDown","Description":"IPv4 Interface Operational State DOWN Event","SrcObjName":"IPv4Intf","EvtId":6,"TimeStamp":"2017-03-28T14:38:32.883912357Z","SrcObjKey":{"IntfRef":"eth25"},"AdditionalData":null}
Client=False, server=False
276
Send close signal
{"Enable":true,"OwnerId":1,"OwnerName":"ASICD","EventName":"PortOperStateUp","Description":"Port Operational State UP Event","SrcObjName":"Port","EvtId":1,"TimeStamp":"2017-03-28T14:38:33.38139292Z","SrcObjKey":{"IntfRef":"eth25"},"AdditionalData":null}
Client=True, server=True
253
{"Enable":true,"OwnerId":1,"OwnerName":"ASICD","EventName":"VlanOperStateUp","Description":"Vlan Operational State UP Event","SrcObjName":"Vlan","EvtId":3,"TimeStamp":"2017-03-28T14:38:33.382071856Z","SrcObjKey":{"VlanId":3050},"AdditionalData":null}
Client=True, server=True
250
{"Enable":true,"OwnerId":1,"OwnerName":"ASICD","EventName":"IPv4IntfOperStateUp","Description":"IPv4 Interface Operational State UP Event","SrcObjName":"IPv4Intf","EvtId":5,"TimeStamp":"2017-03-28T14:38:33.382852609Z","SrcObjKey":{"IntfRef":"eth25"},"AdditionalData":null}
Client=True, server=True
272
Send close signal
- 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 662 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 1068 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 1239 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
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
esphome/esphome.io#7657 ·
Los mantenedores suelen responder en 1 día
-
comp/gateway comp/plugins duplicate P3 type/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
NousResearch/hermes-agent#137019 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Kumo-Tabular weights unreachable behind restrictive egress proxies (Xet + plain HTTP both fail)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
NVIDIA/structured-data-models#1091 ·
Los mantenedores suelen responder en 1 día
-
[work-item] adam-adae-worsening-emergence: conform spec.yaml to the specification style contract (REQ-1280)Posiblemente ocupada @muse-yamaa-bot la tomó hoy. Abiertowork-item
Dificultad 1/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día