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

stream_socket_client(): Unable to connect to tcp://0.0.0.0:2208 #48

Open
younisch96 opened this issue Mar 12, 2023 · 14 comments
Open

stream_socket_client(): Unable to connect to tcp://0.0.0.0:2208 #48

younisch96 opened this issue Mar 12, 2023 · 14 comments

Comments

@younisch96
Copy link

I am getting the following error

(1)Warning: stream_socket_client(): Unable to connect to tcp://0.0.0.0:2208 (The requested address is not valid in its context) in \lin_binance\vendor\workerman\globaldata\src\Client.php on line 66

(2)Fatal error: Uncaught Exception: The requested address is not valid in its context in\vendor\workerman\globaldata\src\Client.php:69 Stack trace: #0

feels like it is unable to connect to binance server

@zhouaini528
Copy link
Owner

You try to use the test example websocket, first open the server and then the client.And the server must be able to access the binance network normally.

@younisch96
Copy link
Author

still same error after opening server first and then client.
i have made two php files socketserver.php and socketclient.php

(1)in socketserver.php the code is following
$binance=new BinanceWebSocket(); $binance->config([ 'baseurl'=>'ws://fstream.binance.com',//usdt future ]); $binance->start();
it gives the output as->Only run in command line mode

(2) in socketsserver.php file code is following.
$action=intval($_GET['action'] ?? 1);//http pattern if(empty($action)) $action=intval($argv[1]);//cli pattern switch ($action){...}
but gives the same error as Warning: stream_socket_client(): Unable to connect to tcp://0.0.0.0:2210 (The requested address is not valid in its context) in \lin_binance\vendor\workerman\globaldata\src\Client.php on line 66

Fatal error: Uncaught Exception: The requested address is not valid in its context in

NOTE: switch action one ,because I am subscribing.

@zhouaini528
Copy link
Owner

I didn't find this problem in my test.

1:run server_usdt_future.php in cli mode
2023-03-14 14-27-54屏幕截图

2:run client_usdt_future.php 3 and 10004 in cli mode, 3 is subscribing, 10004 is the subscription result.
2023-03-14 14-28-50屏幕截图

@younisch96
Copy link
Author

How can i echo this result data to the browser instead of CLI?I also want to save the data in my DB so how can I do in PHP?

@zhouaini528
Copy link
Owner

You can run the client directly in the browser usdt_ future.php.There are many ways for PHP to save databases online, but I suggest storing them in Redis first.

@younisch96
Copy link
Author

Can not I get the results directly in php without running this CLI thing?

@zhouaini528
Copy link
Owner

server_usdt_future.php must be run in CLI mode, client_usdt_future.php has no restrictions.

@younisch96
Copy link
Author

same error in CLI mood also
lin_cli_error

@younisch96
Copy link
Author

any response plz?

@zhouaini528
Copy link
Owner

same error in CLI mood also lin_cli_error

must be in Linux system.

@younisch96
Copy link
Author

thank u ,in linux it works perfectly.by using client_usdt_future.php,it outputs the following ticker info
{"btcusdt@miniTicker":{"stream":"btcusdt@miniTicker","data":{"e":"24hrMiniTicker","E":1679910170338,"s":"BTCUSDT","c":"27903.60","o":"27658.10","h":"28186.90","l":"27590.60","v":"413055.926","q":"11507899578.52"}}}

but it only returns one time. when i run the while loop. my browser stucks,i am running the following code.

$data=$binance->getSubscribes(); print_r(json_encode($data)); while(1){ pcntl_alarm(0); sleep(1); $data=$binance->getSubscribes(); print_r(json_encode($data)); }

@zhouaini528
Copy link
Owner

If you want the browser to continuously output results, you can use javascript ajax technology to implement and access the client_ usdt_ future.php。 You can also output results in CLI mode without getting stuck.

@younisch96
Copy link
Author

thank u. then what is the purpose of given while loop?

@zhouaini528
Copy link
Owner

zhouaini528 commented Mar 28, 2023

thank u. then what is the purpose of given while loop?

You need to understand what a daemon.The purpose of the loop is to facilitate the output of the displayed data, all of which are in the linux system cli mode. You can try it on the command line cli and you will know.

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