Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python websocket client : issue #70

Open
lircstar opened this issue Jan 12, 2021 · 2 comments
Open

python websocket client : issue #70

lircstar opened this issue Jan 12, 2021 · 2 comments

Comments

@lircstar
Copy link

lircstar commented Jan 12, 2021

I use python websocket connect nopoll server, create the issue:
line 141, in read_response
raise EOFError("connection closed while reading HTTP status line") from exc

the python handshake with server in function read_line function receive 0 byte data. no header?
I must use nopoll_conn_opts_add_origin_header ?

my javascript websocket is right to connect the server.

@francisbrosnan
Copy link
Member

Can you post full code example you using to trigger this error? Also post full code example for server side you are running with noPoll so we can reproduce your error...

@lircstar
Copy link
Author

Can you post full code example you using to trigger this error? Also post full code example for server side you are running with noPoll so we can reproduce your error...

// PYTHON ERROR: version(python3.7)
Traceback (most recent call last):
File "D:\app\miniconda3\lib\site-packages\websockets\http.py", line 139, in read_response
status_line = await read_line(stream)
File "D:\app\miniconda3\lib\site-packages\websockets\http.py", line 219, in read_line
raise EOFError("line without CRLF")
EOFError: line without CRLF

// nopoll server part:
#include
#include <nopoll.h>

void listener_on_message(noPollCtx* ctx, noPollConn* conn, noPollMsg* msg, noPollPtr user_data) {

auto data = nopoll_msg_get_payload(msg);
printf("msg : %s\n", data);
nopoll_conn_send_text(conn, "Message received", 16);

return;
}

int main() {

noPollCtx* ctx = nopoll_ctx_new();

if (!ctx)
{
return -1;
}

noPollConn* listener = nopoll_listener_new(ctx, "0.0.0.0", "8888");
if (!nopoll_conn_is_ok(listener)) {
return -2;
}

nopoll_ctx_set_on_msg(ctx, listener_on_message, NULL);
nopoll_loop_wait(ctx, 0);

return 0;
}

python websockets part:
import asyncio
import websockets
message = [
'DEAL B0,4,8,12,16,17,20,24,28,32,33,36,37,44,48,49,50',
'BID A0'
]

async def hello():
async with websockets.connect(
'ws://127.0.0.1:8888/') as websocket:
for name in message:
await websocket.send(name)
print(name)
greeting = await websocket.recv()
print(greeting)

if name == 'main':
asyncio.get_event_loop().run_until_complete(hello())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants