Comments (10)
I would start by hardcoding the address for a test. Are you sure that localhost is translated?
from php-websocket-client.
Yes, my connection from javascripts is (localhost:9235), I can connect and send messages to the server and I receive the response without problem.
What I can't get is to connect the client from php to the same server.
from php-websocket-client.
'localhost?idphonenumber='...
is not a valid host.
Query parameters ('?id...) should go into the $path parameter in the constructor:
PHP-websocket-client/src/Client.php
Line 86 in a40a6bf
That differs from the WebSocket javascript class which takes a full URL (host + query parameters)
from php-websocket-client.
With or without parameters, it does not make the connection. I am using docker and port 9235 is open.
from php-websocket-client.
Ratchet server runs in the same docker container as the php script client ?
If not, what is the network_mode ? host ?
I have a project which runs on docker with Ratchet with PHP client and javascript client (with text & binary socket)
https://github.com/Trismegiste/eclipse-wiki
from php-websocket-client.
Host and path is not necessarily the same thing.
You want to specify the path, not the host.
The implementation might be a little clumsy - I don't remember why host is not a part of path...?
Try something like this:
path: '127.0.0.1?idphonenumber=12345678'
( 'localhost' is not translated to 127.0.0.1 )
from php-websocket-client.
The Ratchet server is in a Docker container called "wasocket".
And the chat container for the client in a separate one called "facturascripts".
The network of both containers is not set, from what I understand it will be the default.
from php-websocket-client.
I still can't get it to work
try {
$headers = '';
$error_string = '';
$sp = new \Paragi\PhpWebsocket\Client(
'localhost',
9235,
$headers,
$error_string,
10,
false,
false,
'127.0.0.1?idphonenumber=' . $phone->idphonenumber);
$sp->write("hello server");
echo "Server responded with: " . $sp->read();
} catch (\Paragi\PhpWebsocket\ConnectionException $e) {
echo "Something gets wrong " . $e->getMessage();
}
from php-websocket-client.
This is my docker-compose.yml
version: '3'
services:
facturascripts:
container_name: facturascripts
build: ./php7.4
restart: always
ports:
- 80:80
volumes:
- ./facturascripts:/var/www/html
wasocket:
build: ./php7.4-wasocket
container_name: wasocket
ports:
- 9235:9235
volumes:
- ./wasocket:/var/www
networks:
proxy:
external: true
from php-websocket-client.
I got it, it connects now. Thanks for the support and help.
from php-websocket-client.
Related Issues (12)
- [Question] Is there a way to setup websocket without terminal? HOT 1
- how to send GET requets body? HOT 1
- [Question] check connection status HOT 2
- Cant seem to connect to Ratchet thru ProxyPass with ssl HOT 2
- could not connect, syntax error HOT 1
- cant connect with wss/:: HOT 9
- read method problem, Reading header from websocket failed HOT 6
- read method mistyped HOT 4
- [Bug] stripos instead of strpos and resolve compare HOT 1
- [Bug] `persistant` set to true for basic example HOT 5
- [Feature] Set custom path in the header HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-websocket-client.