Symfony2 - GeniusesOfSymfony/WebSocketBundle ssl error connection - symfony

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 ?

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.

Laravel Homestead Mailhog Error listening on socket: listen tcp 0.0.0.0:1025: bind: address already in use

I am struggling to make MailHog work in my Laravel Homestead VM.
If I browse http://localhost:8025/, the web browser says it can't find it.
Then, in the command line, when executing $ mailhog, I get the following error:
Error listening on socket: listen tcp 0.0.0.0:1025: bind: address
already in use
Moreover, if I execute $ mailhog --invite-jim then I get:
2021/09/13 22:49:22 Using in-memory storage 2021/09/13 22:49:22 [SMTP]
Binding to address: 0.0.0.0:1025 [HTTP] Binding to address:
0.0.0.0:8025 2021/09/13 22:49:22 Serving under http://0.0.0.0:8025/ 2021/09/13 22:49:22 [SMTP] Error listening on socket: listen tcp
0.0.0.0:1025: bind: address already in use
Here is my .env config file
.env
MAIL_MAILER=smtp
MAIL_HOST=localhost
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=reply#app.io
MAIL_FROM_NAME="${APP_NAME}"
Does anyone know or can shed some light how to make MailHog work?
Mailhog web interface is clearly listening at the 8025 port. The localhost or 127.0.0.1 address may not work by default.
Take a look at both the /etc/hosts and Homestead.yml file
$ sudo vim /etc/hosts
$ vim Homestead.yml
Look for the address that Homestead is working on. In this case it's 192.168.10.10 or 192.168.56.56
So now try
http://192.168.10.10:8025 or http://192.168.56.56:8025
And it should be working now

JDBC /TCP nginx to azure sql db fails with permission denied 13

hi i like to connect through an nginx to an azure sql db to have an single point of access to my network.
Goal is to access to the nginx publicip:1234 which is translated to mydb.database.microsoft.com:1433
I have configured a nginx on centos with stream addon.
config looks like:
stream {
upstream mssql {
server mydb.database.microsoft.com:1433;
server mydb.database.microsoft.com:1433;
}
server {
listen 1234;
proxy_pass mssql;
}
}
The mssql is configured to accept connections from the publicip of the nginx machine as well as has a service endpoint to the vnet where the nginx is connected to.
When i try to connect to the db through the nginx i receive the following error message:
.... connect() to IPOFDB:1433 failed (13: Permission denied) while connecting to upstream, client: MYIP server:0.0.0.0:1234 ...
The only idea why it my fail is that the outgoing ip from nginx is not the publicip which is whitelisted for the db and it does not use the vnet endpoint connection.
any ideas.
Thanks for your help.
Disable SElinux permanently and reboot
or
semanage port -a -t http_port_t -p tcp 1234

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.

websocket on HTTPS

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?

Resources