Websocket client with PHP

吃可爱长大的小学妹 提交于 2019-12-25 01:57:59

问题


Hello I use the following project class:
https://github.com/paragi/PHP-websocket-client

When I try to connect to the websocket I have the following error: Server did not accept to upgrade connection to websocket. and in the variable $ reaponse_header I have ê☻♥Û256

My websocket works fine and the client connection works on a web browser via javascript

I absolutely need to side me to the websocket as a client via php

J'ai le retour suivant:

Variables in local scope (#3):
  $address = 'ws://localhost/'
  $buffer = 'ê\002\003Û'
  $errno = 0
  $errstr = ''
  $expectedResonse = *uninitialized*
  $fragment = ''
  $header = 'GET / HTTP/1.1\r\nhost: localhost:9300\r\nuser-agent: websocket-client-php\r\nconnection: Upgrade\r\nupgrade: websocket\r\nsec-websocket-key: TSF0NT1lXT1BM1ZmaW1mMA==\r\nsec-websocket-version: 13\r\n\r\n'
  $headers = array ('host' => 'localhost:9300', 'user-agent' => 'websocket-client-php', 'connection' => 'Upgrade', 'upgrade' => 'websocket', 'sec-websocket-key' => 'TSF0NT1lXT1BM1ZmaW1mMA==', 'sec-websocket-version' => '13')
  $host = 'localhost'
  $host_uri = 'tcp://localhost'
  $key = 'TSF0NT1lXT1BM1ZmaW1mMA=='
  $keyAccept = *uninitialized*
  $matches = array ()
  $metadata = array ('timed_out' => FALSE, 'blocked' => TRUE, 'eof' => TRUE, 'stream_type' => 'tcp_socket/ssl', 'mode' => 'r+', 'unread_bytes' => 0, 'seekable' => FALSE)
  $pass = ''
  $path = '/'
  $path_with_query = '/'
  $port = 9300
  $query = ''
  $response = '\n\n\nê\002\003Û\n'
  $scheme = 'ws'
  $url_parts = array ('scheme' => 'ws', 'host' => 'localhost', 'port' => 9300)
  $user = ''

Do you have a solution to the problem?
Regards

来源:https://stackoverflow.com/questions/55262266/websocket-client-with-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!