websocket on HTTPS - symfony

In local server i donot face this issue, but in production server with has https it does not work
Firefox ne peut établir de connexion avec le serveur à l’adresse
wss://kergafa.com:8081/.
I have tried multiple time but could not find/understand Where the problem lies?
my conf.yml
gos_web_socket:
server:
port: 8081 #The port the socket server will listen on
host: kergafa.com #The host ip to bind to
router:
resources:
- '#SkiesAdherentBundle/Resources/config/pubsub/routing.yml
client:
firewall: main
session_handler: '#session.handler.pdo'
pushers:
wamp:
host: kergafa.com
port: 8081
when I start the server:
[2017-01-06 04:33:12] websocket.INFO: Starting web socket
[2017-01-06 04:33:12] websocket.INFO: Register periodic callback Gos\Bundle\WebSocketBundle\Periodic\PdoPeriodicPing, executed each 20 seconds
[2017-01-06 04:33:12] websocket.INFO: Launching Ratchet on kergafa.com:8081 PID: 7698
so its works
ctunnel conf
[websockets]
accept = 8080
connect = kergafa.com:8081
it says:
[Started: /etc/stunnel/stunnel.conf] stunnel.
the grep 8080 result
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 7694/stunnel4

I edited your post. In the config.yml you have this:
router:
resources:
- '#SkiesAdherentBundle/Resources/config/pubsub/routing.yml
But that looks wrong. I think a simple change:
router:
resources:
- #SkiesAdherentBundle/Resources/config/pubsub/routing.yml
Maybe that's the problem?

Related

Haproxy in docker cannot access device's localhost via "host.docker.internal"

I need to configure Haproxy for local testing.
The goal is to have 3 services
haproxy in docker container
listening http app on device's (macOS) localhost
a client app sending request through haproxy to the listening app (number 2.)
docker-compose.yml configuration for the proxy is
proxy_server:
image: haproxy:2.7.0-alpine
container_name: proxy_server
user: root # I used this to install curl in the container
ports:
- '3128:80' # haproxy itself
- '20005:20005' # configured proxy in haproxy.cfg
restart: always
volumes:
- ./test/proxy_server/config:/usr/local/etc/haproxy # this maps the haproxy.cfg file into the container
extra_hosts:
- 'host.docker.internal:host-gateway' # allows the proxy to access device's localhost on linux
haproxy.cfg is
defaults
timeout client 5s
timeout connect 5s
timeout server 5s
timeout http-request 5s
listen reverse-proxy
bind *:20005
mode http
option httplog
log stdout format raw local0 debug
When the listening app (2.) listens on localhost:56454, I can connect into the haproxy container, install curl and connect to the listening app via host.docker.internal host.
/ # curl -v -I http://host.docker.internal:56454
* Trying 192.168.65.2:56454...
* Connected to host.docker.internal (192.168.65.2) port 56454 (#0)
> HEAD / HTTP/1.1
> Host: host.docker.internal:56454
> User-Agent: curl/7.86.0
> Accept: */*
This is correct.
The problem is that I am not able to send request through the proxy to the same URL (http://host.docker.internal:56454) because the proxy logs
172.22.0.1:56636 [10/Dec/2022:13:50:22.601] reverse-proxy reverse-proxy/<NOSRV> 0/-1/-1/-1/0 503 217 - - SC-- 1/1/0/0/0 0/0 "POST http://host.docker.internal:56454/confirmation HTTP/1.1"
and the client gets following response:
HTTP Status 503: <html><body><h1>503 Service Unavailable</h1>\nNo server is available to handle this request.\n</body></html>
Also, the request passes correctly when I use the following docker-compose.yml configuration with ubuntu/squid image instead of the haproxy one
proxy_server:
image: ubuntu/squid
container_name: proxy_server
ports:
- '3128:3128'
restart: always
extra_hosts:
- 'host.docker.internal:host-gateway' # allows the proxy to access device's localhost on linux
So, I guess the problem is that haproxy somehow does not see the service on http://host.docker.internal:56454 even though the service is accessible from the container.
I've also tried ubuntu and debian versions of the haproxy image and it still does not work correctly.
Any idea how to fix it?
Edit:
Investigating <NOSRV>... No clue how to fix it yet.

Liveness and readiness probe connection refused

I keep getting this error when I try to setup liveness & readiness prob for my awx_web container
Liveness probe failed: Get http://POD_IP:8052/: dial tcp POD_IP:8052: connect: connection refused
Liveness & Readiness section in my deployment for the container awx_web
ports:
- name: http
containerPort: 8052 # the port of the container awx_web
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 8052
initialDelaySeconds: 5
periodSeconds: 5
readinessProbe:
httpGet:
path: /
port: 8052
initialDelaySeconds: 5
periodSeconds: 5
if I test if the port 8052 is open or not from another pod in the same namespace as the pod that contains the container awx_web or if I test using a container deployed in the same pod as the container awx_web i get this (port is open)
/ # nc -vz POD_IP 8052
POD_IP (POD_IP :8052) open
I get the same result (port 8052 is open) if I use netcat (nc) from the worker node where pod containing the container awx_web is deployed.
for info I use a NodePort service that redirect traffic to that container (awx_web)
type: NodePort
ports:
- name: http
port: 80
targetPort: 8052
nodePort: 30100
I recreated your issue and it looks like your problem is caused by too small value of initialDelaySeconds for the liveness probe.
It takes more than 5s for awx container to open 8052 port.
You need to wait a bit longer for it to start. I have found out that setting it to 15s is enough for me, but you may require some tweaking.
In my case this issue has occurred because I've configured the backend application host as localhost. The issue is resolved when I changed the host value to 0.0.0.0 inside my app properties.
Use the latest built docker image after making this change.
Most likely your application couldnt startup or crash little after it start up . It may due to insufficient memory and cpu resource. Or one of the awx dependency not setup correctly like postgreslq & rabbit.
Did you check that if your application works correctly without probes? I recommend do that first. Examine the pods stats little bit to ensure its not restart.

How to make ngrok client listen a specific hostname instead of localhost?

My yaml config is like this:
yarn:
hostname: "ngrok.xfl.me:810"
remote_port: 810
proto:
tcp: 8088
My purpose is:
Forwarding https://ngrok.xfl.me:810-> 192.168.0.104:8088
But by default, as the config above, ngrok client just listen to 127.0.0.1. So it failed to connect.
How can I make the ngrok client listen to a certain hostname 192.168.0.104 instead of localhost
Thanks a lot!
It was solved with:
yarn:
hostname: "ngrok.xfl.me:810"
remote_port: 810
proto:
tcp: 192.168.0.104:8088

Websocket doesn't work in server 127.0.0.1:8000

I'm using Gos Web Socket Bundle in Symfony and I try to work in demo they give. I'm very confuse about the port because the it works, if the port is 127.0.0.1:1337 but when I run the server of symfony it generate 127.0.0.1:8000, so I try to add it here'
gos_web_socket:
server:
port: 8000 #The port the socket server will listen on
host: 127.0.0.1 #The host ip to bind to
router:
resources:
- '#AppBundle/Resources/config/pubsub/routing.yml'
and the websocket in javascript
var websocket = WS.connect("ws://127.0.0.1:8000");
When the time I display it in my page. I always get bad request. But If I use WS.connect("ws://127.0.0.1:1337"); it works, and the server I run from symfony is 127.0.0.1:8000. I'll be glad if you explain the reason why I need to use 1337 port than 8000
IMHO the port 8000 is already occupied with some other service. I would be suspicious of PHP builtin server, so check the port which is the server listening on by php bin/console server:status. If the port is 8000, then stop it php bin/console server:stop and start on some other port php bin/console server:start 127.0.0.1:8000 and the websocket shoud then be available on 8000.

Symfony2 - GeniusesOfSymfony/WebSocketBundle ssl error connection

I need to configure my project with ssl.
So, i have Mamp Pro, and i have created a new Generated SSL certificate.
My server is running via Https,
Right now, i cant connect to server via Javascripts client :
After 10 sec, this is the javascripts error that ive got :
WebSocket connection to 'wss://127.0.0.1:4000/' failed: Error in connection establishment: net::ERR_TIMED_OUT
(index):111 Disconnected for Connection could not be established. with code 3
and this is my configuration :
gos_web_socket:
pushers:
wamp:
host: 127.0.0.1
port: 4000
server:
port: 4000 #The port the socket server will listen on
host: 127.0.0.1 #The host ip to bind to
router:
resources:
- #AppBundle/Resources/config/pubsub/routing.yml
This is the javascripts code :
var websocket = WS.connect("wss://127.0.0.1:4000");
websocket.on("socket/connect", function(session)
Any help please ?

Resources