Comments (10)
@gborrageiro-ld @andrea-mucci @engn33r
I put together a websocket throughput test in dez, which is an async network stack built on rel. The new test is in the latest version, 0.10.10.1, which can be installed thusly:
pip install dez
To run the test, first run this:
dez_test wsecho
That starts up a pretty basic websocket echo server (code) with a couple extra features.
Then, in a different terminal, run:
dez_test wsc
That (code) will prompt you to select a test configuration (high throughput in upstream/downstream/both/neither directions). It will then start up a WebSocketApp (with rel dispatcher) and proceed to direct heavy traffic in the specified direction. Anyway, it runs fine for me in every configuration.
Is anyone able to reproduce the issue using this test? Feel free to modify the code. Or is there a different websocket server that has this issue? For whatever reason, it doesn't seem to be a problem with dez.
Anyway, this shouldn't be hard to fix, if anyone can come up with a reliable repro - thoughts and test cases welcome!
from websocket-client.
@gborrageiro-ld thanks for the detailed report! Do you get the same SSLEOFError with the default (unspecified) dispatcher - that is, connected to the same endpoint, but without rel?
Also, since it looks like it's throwing this error in the course of trying to send a pong, I'm wondering whether the same problem is still encountered if you don't specify ping_interval and ping_timeout.
from websocket-client.
hi @bubbleboy14,
I have two streams, one authenticated and the other is unauthenticated. I depend on a dispatcher like rel
to handle multiple streams; what alternatives would you suggest?
If I remove the ping/pong, then the exception does eventually occur, yes.
Thanks
Gabriel
from websocket-client.
I removed rel and let the busy, unauthenticated stream run, and I do not see this segmentation fault.
from websocket-client.
Hey @gborrageiro-ld I created a standalone test from the example code you provided:
import rel, websocket
BASEURL = "wss://fstream.binance.com/stream?streams=btcusdt@bookTicker/btcusdt@depth20@100ms/btcusdt@aggTrade/btcusdt@markPrice@1s/btcusdt@"
variants = ["bookTicker", "forceOrder"]
def onmsg(ws, msg):
print("received:", msg)
for v in variants:
ws = websocket.WebSocketApp(BASEURL + v, on_message=onmsg)
ws.run_forever(dispatcher=rel, reconnect=3, ping_interval=180, ping_timeout=60)
rel.dispatch()
I've been running it for a while, and I haven't gotten that SSLEOFError. Does it take a long time? Are you able to reproduce the issue with this test case? If not, could you modify it to produce the error?
Anyway, thanks a million for the excellent report, we should be able to track this one down. LMK how it goes!
from websocket-client.
Hi,
I have the same error but with a different approach
i have a client that only send data to a server
.....
self.socket = websocket.WebSocket()
self.socket.connect(self.url)
#this is the method that send a command
def command(content):
self.socket.send(....)
nothing special, the problem is that if i start to send messages from a loop, like:
for item in items:
__method_that_send_ws_message()
in a certin point a get a failure:
File "/home/andrea/PycharmProjects/ArchAI/archai/venv/lib/python3.10/site-packages/websocket/_core.py", line 283, in send
return self.send_frame(frame)
File "/home/andrea/PycharmProjects/ArchAI/archai/venv/lib/python3.10/site-packages/websocket/_core.py", line 311, in send_frame
l = self._send(data)
File "/home/andrea/PycharmProjects/ArchAI/archai/venv/lib/python3.10/site-packages/websocket/_core.py", line 525, in _send
return send(self.sock, data)
File "/home/andrea/PycharmProjects/ArchAI/archai/venv/lib/python3.10/site-packages/websocket/_socket.py", line 170, in send
return _send()
File "/home/andrea/PycharmProjects/ArchAI/archai/venv/lib/python3.10/site-packages/websocket/_socket.py", line 147, in _send
return sock.send(data)
File "/usr/lib/python3.10/ssl.py", line 1206, in send
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426)
the strange thing is that before the error i have already sent a lot of messages, the problem come if a send the messages from a loop in a method
from websocket-client.
@andrea-mucci hm, interesting. the python ssl docs say:
A subclass of SSLError raised when the SSL connection has been terminated abruptly. Generally, you shouldn’t try to reuse the underlying transport when this error is encountered.
i don't know enough about the inner workings (of python's ssl module) to say how wide an array of circumstances (beyond a simple connection drop) can lead to this.
however, since you and @gborrageiro-ld both describe high throughput situations, i wonder whether, perhaps, some buffer is filling up... i mean, it really shouldn't be something like that. do you have any thoughts on this, @engn33r ?
i notice you're both running py3.10 - this may be related.
@andrea-mucci are you using the rel dispatcher?
can anyone provide a concise repro?
from websocket-client.
Checking any search engine for "python EOF occurred in violation of protocol" shows this a common error message and often related to the SSL library. I suggest sharing the OS that you are using (Windows, Mac, *nix) and the output of these commands when such an SSL error is encountered:
openssl version
python3 -c "import ssl; print(ssl.OPENSSL_VERSION); import websocket; print(websocket.__version__)"
python3 -V
from websocket-client.
from websocket-client.
@engn33r @gborrageiro-ld @andrea-mucci
I just encountered this issue myself! This patch fixed it for me:
Does it fix things for you guys?
It's just two small changes in read() (in run_forever()): 1) check for SSLEOFError; 2) pass bool(reconnect) to handleDisconnect().
@engn33r, these seem like logical tweaks, right? Fixes the issue for me, anyway.
LMK what you think!
from websocket-client.
Related Issues (20)
- 1.7.0 being used in python 3.7 HOT 1
- Exceptions are "protected" HOT 7
- WebSocketApp connection not closing as expected HOT 1
- valueerror:too many file descriptors in select() HOT 4
- Handling of KeyboardInterrupt
- WebApp proxy configuration does not work
- ensuring regular callbacks to WebSocketApp's on_message() on the same thread
- Need help on connecting with custom socket HOT 1
- no_proxy is inconsistent with urllib and makes mixing libraries HAVE to put . when not needed if this library is not in use.
- Automatic reconnection docs misleading HOT 1
- on_error callback stops being called after first reconnection HOT 1
- Multiple on_open events HOT 10
- No route to host----when access IPv6 address failed,no attempt was made to access an IPv4 address HOT 1
- why on_close only was called once, so it causes the client to reconnect automatically only once, even I set reconnect parameter. HOT 8
- Is there a way to send a message every X seconds to the server? HOT 4
- reconnection fails when server returns op_code = ABNF.OPCODE_CLOSE HOT 5
- Reconnection with disptacher, issue with close HOT 7
- [Feature request] more clear error hint when number of open files exceeds the OS limit HOT 1
- on_open && ws.send() HOT 5
- Sending data that is too large when using the send() method can lead to failure.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from websocket-client.