mandrewcito / signalrcore

SignalR Core python client
https://mandrewcito.github.io/signalrcore/
MIT License
115 stars 53 forks source link

invoke equivalend command in this library #99

Open mywebartist opened 1 year ago

mywebartist commented 1 year ago

im beginner in life so i dont know anything.

i have angular application which im trying to rewrite some parts in python using signalR. I found this library and I'm able to make connection to the signalR hub which is on my system running with .net, it works fine with the angular application and that code is below: anuglar code(works fine) this.connection.invoke("ConnectFrontend", sessionId)

when this code runs i can see the function trigger in the Visual studio on below function: visual studio code:

        [HubMethodName("ConnectFrontend")]
        public async Task ConnectFrontend(string sessionId)

in my python equivalend code I wrote this but when its called the visual studio break point does not trigger anything, which tells me that invocation did not work. what am I doing wrong. python code

        send_callback_received = threading.Lock()
        send_callback_received.acquire()
        this.connection.send(
            "ConnectFrontend", # Method
            [sessionId], # Params
            lambda m: print('ConnectFrontend success')) # Callback
        if not send_callback_received.acquire(timeout=1):
            print("CALLBACK NOT RECEIVED")

on top of that this is the console log from python

(base) PS D:\signalRApp> & C:/signalRApp/main.py
SignalRService - connectFront SignalR URL:  http://localhost:5008/chat/
Connection started
Negotiate url:http://localhost:5008/chat/negotiate
Response status code200
start url:ws://localhost:5008/chat/?id=ZtV9ie1ci9bSIfCA5_lmAw
sendConnectionMessage
Sending message InvocationMessage: invocation_id 553ab839-f4f7-4cb1-992e-f060fbffc7e1, target ConnectFrontend, arguments [7619976]
{"type": 1, "headers": {}, "target": "ConnectFrontend", "arguments": [7619976], "invocationId": "553ab839-f4f7-4cb1-992e-f060fbffc7e1"}▲
++Sent raw: b'\x81\xfe\x00\x88\x96;-\xde\xed\x19Y\xa7\xe6^\x0f\xe4\xb6\n\x01\xfe\xb4SH\xbf\xf2^_\xad\xb4\x01\r\xa5\xeb\x17\r\xfc\xe2Z_\xb9\xf3O\x0f\xe4\xb6\x19n\xb1\xf8UH\xbd\xe2}_\xb1\xf8OH\xb0\xf2\x19\x01\xfe\xb4Z_\xb9\xe3VH\xb0\xe2H\x0f\xe4\xb6`\x1a\xe8\xa7\x02\x14\xe9\xa0f\x01\xfe\xb4RC\xa8\xf9XL\xaa\xffTC\x97\xf2\x19\x17\xfe\xb4\x0e\x18\xed\xf7Y\x15\xed\xaf\x16K\xea\xf0\x0c\x00\xea\xf5Y\x1c\xf3\xaf\x02\x1f\xbb\xbb]\x1d\xe8\xa6]O\xb8\xf0X\x1a\xbb\xa7\x19P\xc0'    
++Sent decoded: fin=1 opcode=1 data=b'{"type": 1, "headers": {}, "target": "ConnectFrontend", "arguments": [7619976], 
"invocationId": "553ab839-f4f7-4cb1-992e-f060fbffc7e1"}\x1e'
--- request header ---
GET /chat/?id=ZtV9ie1ci9bSIfCA5_lmAw HTTP/1.1
Upgrade: websocket
Host: localhost:5008
Origin: http://localhost:5008
Sec-WebSocket-Key: 6ONdmIOlIbiB+lxjbPQ2HA==
Sec-WebSocket-Version: 13
Connection: Upgrade

-----------------------
--- response header ---
HTTP/1.1 101 Switching Protocols   
Connection: Upgrade
Date: Mon, 02 Jan 2023 13:56:57 GMT
Server: Kestrel
Upgrade: websocket
Sec-WebSocket-Accept: oEumezQHVLnXpddyF8HqH65rw/Q=
-----------------------
-- web socket open --
Sending message <signalrcore.messages.handshake.request.HandshakeRequestMessage object at 0x0000027EB3849820>
{"protocol": "json", "version": 1}▲
++Sent raw: b'\x81\xa3\xd25\x8f\xed\xa9\x17\xff\x9f\xbdA\xe0\x8e\xbdY\xad\xd7\xf2\x17\xe5\x9e\xbd[\xad\xc1\xf2\x17\xf9\x88\xa0F\xe6\x82\xbc\x17\xb5\xcd\xe3H\x91'
++Sent decoded: fin=1 opcode=1 data=b'{"protocol": "json", "version": 1}\x1e'
++Rcv raw: b'\x81F{"error":"An unexpected error occurred during connection handshake."}\x1e'
++Rcv decoded: fin=1 opcode=1 data=b'{"error":"An unexpected error occurred during connection handshake."}\x1e'       
Message received{"error":"An unexpected error occurred during connection handshake."}▲
Evaluating handshake {"error":"An unexpected error occurred during connection handshake."}▲
An unexpected error occurred during connection handshake.
-- web socket error --
NoneType: None

<signalrcore.transport.websockets.websocket_transport.WebsocketTransport object at 0x0000027EB3849040> An unexpected error occurred during connection handshake.
An unexpected error occurred during connection handshake. <class 'str'>
connection closed
connection opened and handshake received ready to send messages
++Rcv raw: b'\x88\x02\x03\xe8'
++Rcv decoded: fin=1 opcode=8 data=b'\x03\xe8'
++Sent raw: b'\x88\x82\xab\xe4\x04h\xa8\x0c'
++Sent decoded: fin=1 opcode=8 data=b'\x03\xe8'
-- web socket close --
1000

connection closed
CALLBACK NOT RECEIVED