Closed momit-litu closed 1 year ago
Hi Momit-litu without looking at your code, i would guess that the problem is that you use wss:// as protocol. Its not supported yet, by PHP. You should not specify the protocol. Please look at the ssl example3 in the readme. https://github.com/paragi/PHP-websocket-client If the explanation seems unclear, please help me make it better.
Best regards Simon
Thank you for the quick response. yes i tried with the ssl option also. but that time i get the following error. i used www.mews.li/ws/connector as the server address elemination the 'wss://", i have also tried with "mews.li/ws/connector" as server adress. but each time i get the following warning
Warning: stream_socket_client(): php_network_getaddresses: getaddrinfo failed: No such host is known. in C:\xampp\htdocs\PHP-websocket-client\websocket_client.php on line 101
Warning: stream_socket_client(): unable to connect to ssl://www.mews.li/ws/connector:443 (php_network_getaddresses: getaddrinfo failed: No such host is known. ) in C:\xampp\htdocs\PHP-websocket-client\websocket_client.php on line 101
have you tried example 3?
yes. websocket_open('www.mews.li/ws/connector',443,$headers,$errstr, 10,true)
e
does it work with echo.websocket.org and your headers?
it's unlikely that a wss service starts with www. Are you sure about the address?
it works with echo.websocket.org
the server address is ok. i have also tried with demo
WebSocketAddress - wss://www.mews.li WebSocketAddress - wss://ws.mews-demo.com
my header cookie keys are also ok i tested. with a http connection with postman
"wss://www.mews.li" is a protocol AND an address. "ws.mews-demo.com" would be just an address. Try without specifying the protocol.
https://mews-systems.gitbook.io/connector-api/guidelines/environments
the above 2 addresses are demo and production both. i tried both without protocol through SSL
they state that you should use: "ws.mews-demo.com" The wss:// part is what this package provides. Not an address.
Hi dear, I was trying to connect with MEWS socket which host is ''wss://ws.mews-demo.com/ws/connector''. the server must need the keys into cookie. i just added that into headers. but i am getting the error:
Warning: stream_socket_client(): unable to connect to wss://ws.mews-demo.com/ws/connector:443 (Unable to find the socket transport "wss" - did you forget to enable it when you configured PHP?) in C:\xampp\htdocs\PHP-websocket-client\websocket_client.php on line 101
I need a help badly. Thanks.
my code of example.php
<?php require "./websocket_client.php"; //$server = 'echo.websocket.org'; $server ='wss://ws.mews-demo.com/ws/connector'; //demo $message = "hello server";
echo "Connecting to server: $server \n"; //demo $headers = ["Cookie: ClientToken=E0D439EE522F44368DC78E1BFB03710C-D24FB11DBE31D4621C4817E028D9E1D; AccessToken=C66EF7B239D24632943D115EDE9CB810-EA00F8FD8294692C940F6B5A8F9453D"];
$sp = websocket_open($server ,443,$headers,$errstr,16); if($sp){ echo "Server responed with: '" . websocket_read($sp,$errstr) ."'\n"; $bytes_written = websocket_write($sp,"hello server"); if($bytes_written){ $data = websocket_read($sp,$errstr); echo "Server responed with: " . $errstr ? $errstr : $data; } } ?>