ASPLes / nopoll

OpenSource WebSocket toolkit
http://www.aspl.es/nopoll
GNU Lesser General Public License v2.1
124 stars 74 forks source link

python websocket client : issue #70

Open lircstar opened 3 years ago

lircstar commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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

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())