Open cardinal-II opened 1 year ago
Any information in the webdev console of the browser?
Any information in the webdev console of the browser?
Connect to ws://127.0.0.1:9001
WebSocket.onopen() called
Hello, I have the same issue. Running tcpdump on the server, I see that the message the client sends is received on the server but it does not seem to go any further than that.
`12:16:11.957597 IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto TCP (6), length 62) imac31.58672 > dodekagon.9001: Flags [P.], cksum 0xe7b8 (correct), seq 1018:1028, ack 130, win 2056, options [nop,nop,TS val 3477527813 ecr 2407652574], length 10 0x0000: 4500 003e 0000 4000 4006 b43d c0a8 02c8 E..>..@.@..=.... 0x0010: c0a8 0264 e530 2329 55de e0f3 f36b 2d8f ...d.0#)U....k-. 0x0020: 8018 0808 e7b8 0000 0101 080a cf46 dd05 .............F.. 0x0030: 8f81 dcde 8184 f4bf 76b7 87d9 12c4 ........v.....
12:16:12.000125 IP (tos 0x0, ttl 64, id 7222, offset 0, flags [DF], proto TCP (6), length 52) dodekagon.9001 > imac31.58672: Flags [.], cksum 0x86a3 (incorrect -> 0x028d), seq 130, ack 1028, win 502, options [nop,nop,TS val 2407681981 ecr 3477527813], length 0 0x0000: 4500 0034 1c36 4000 4006 9811 c0a8 0264 E..4.6@.@......d 0x0010: c0a8 02c8 2329 e530 f36b 2d8f 55de e0fd ....#).0.k-.U... 0x0020: 8010 01f6 86a3 0000 0101 080a 8f82 4fbd ..............O. 0x0030: cf46 dd05 .F.. ` It seems like the onConnect is never called. The onIdle runs every 60 seconds though with the correct agent ip and port
I have added a line in WebSocketServer.php in the idle method like so:
$this->sendMessageToAllClients($agent->server(), 'Hello idle agent');
And this works. The client receives it.
If anyone happens to stumble across this, the workaround is the following. In file fatfree-core/cli/ws.php do the following changes
Line 50 remove the events from the protected and declare it public
protected $addr, $ctx, $wait, $sockets, $protocol, $agents=[]; //$events=[]; public $events=[];
Then line 324 at the definition of the class Agent
protected //$server, $id, $socket, $flag, $verb, $uri, $headers; public $server;
Remove the $server from the protected and make it public. I understand that this might be overwritten if I update Fat Free (don't really understand the implications of my change though ), but it works
I can connect to the WebSocket server with clients in a terminal and with index.html in a browser. But I can't send or receive messages. In the terminal with the running Websocket server, every minute I see:
2023-10-14 18:22:40 | 4.194 MB | Agent 127.0.0.1:58920 idles
Nothing more. In the browser:
How to make it work?