Failed WebSocket Connection (Pusher.com and Laravel) - laravel

I have a problem with websocket connection.
This is the error in the browser. I am getting a message in pusher.com just then I refresh the page, but not every time the websocket connects. I think something is wrong with my .env file, but not sure.
.env file:
PUSHER_APP_ID=...
PUSHER_APP_KEY=...
PUSHER_APP_SECRET=...
PUSHER_HOST=null
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=eu
What host should I write to solve it? Or the problem is somewhere else?

When connecting to Pusher you do not need to set the host or port. You can remove these variables and then the library will be able to connect to Pusher.

Related

Laravel WebSockets - deployment - fails to connect the websocket

I am trying to deploy my laravel project with websockets built on Beyond Code's package.
My server is on AWS and i'm using WHM.
on the cPanel's terminal i'm running the line php artisan websockets:serve
and i get the result Starting the WebSocket server on port 6001...
when i'm loading the page with the websocket's connection sometimes i get the error failed: Error during WebSocket handshake: Unexpected response code: 200
and sometimes i get the error failed: WebSocket is closed before the connection is established.
On AWS EC2's Security Groups i allowed the Custom TCP port 6001 and 6002
Any suggestions to fix it?
Maybe a good deployment tutorial for Laravel WebSockets?
I'm looking for answers all over the internet and i get nothing useful.

Connection could not be established with host laravel 5.4?

i am using virtual host but phpmyadmin is also pointed to virtual host ip and working perfectly
when i register a account on my laravel project i am getting following error .
Connection could not be established with host [No connection could be
made because the target machine actively refused it.
#10061]
in my logs
#10061] in C:\xampp\htdocs\upload\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php:268
Stack trace:
This error can be caused by having the wrong values configured for MAIL_PORT, MAIL_ENCRYPTION, and occasionally MAIL_HOST.
swiftmailer is the library that sends email. You're getting the error when you register and Laravel tries to send an email.
"...the target machine actively refused..." means that the host resolved successfully, but the other computer either has a firewall blocking the port or no process is listening on that port.
Your mailer service should tell you what port to use in their documentation. If using MAIL_DRIVER=smtp and MAIL_ENCRYPTION=tls, typically this will be port 587, 465, or 25.

Poloniex Push WAMP API through Autobahn dropping connection to peer tcp

I tried to connect to the Push API in poloniex using python and followed the instructions on the answer here:
How to connect to poloniex.com websocket api using a python library
However I keep getting this error:
2017-06-25T04:07:04 dropping connection to peer tcp:104.20.13.48:443 with abort=True: WebSocket opening handshake timeout (peer did not finish the opening handshake in time)
Anyone know what's going on here? I can't figure it out from online documentation. Thanks!
As per #Cyphrags suggestion, I was able to get my autobahn websocket to work outside of localhost by increasing openHandshakeTimeout with factory.setProtocolOptions
factory.protocol = MyClientProtocol
factory.setProtocolOptions(failByDrop=False, openHandshakeTimeout=90, closeHandshakeTimeout=5)
Solution found via https://github.com/crossbario/crossbar/issues/930. Perhaps the reason it is needed has something to do with slow DNS routing taking longer than the default handshake time.

Sending email from Laravel using Gmail

I have been using Laravel for a little while now, so thought I would dive into HTML emails, so I followed a tutorial.
The issue I have, as well as seemingly quite a few others is this:
Swift_TransportException in StreamBuffer.php line 269:
Connection could not be established with host smtp.gmail.com
[A connection attempt failed because the connected party did not properly respond
after a period of time, or established connection failed because connected host has failed to respond.
#10060]
My .ENV
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=465
MAIL_USERNAME=EMAIL
MAIL_PASSWORD=PASS
MAIL_ENCRYPTION=tls
I have also tried ports 25 and others suggested, as well as ssl as opposed to tls, I have also tried using sendmail as opposed to smtp.
Further to this, I have the same issue when trying with an Outlook account.
I even enabled the option to accept items from less secure applications.
Anyone else experiencing these issues?
UPDATE:
I am having the same issues with Mail Trap, could it be my laravel install?
Also tried with a fresh install...
FURTHER UPDATE
When I ping any site, I get request timed out, which means I think my router is blocking me?
According with help for administrator page of Google, when you try to connect by port 465 this requires encryption SSL, on the contrary if you use TLS you should set the port to 587, try changing the port on your .env file.
Reference: https://support.google.com/a/answer/176600?hl=es
.env file
MAIL_DRIVER=smtp
MAIL_HOST=smtp.gmail.com
MAIL_PORT=587
MAIL_USERNAME=youremailaddress
MAIL_PASSWORD=yourownpassword
MAIL_ENCRYPTION=tls

how to use Redis Server Detection in laravel?

1-Xampp
2-laravel 5.1
3-run localhost:8000
class in function
$redis = LRedis::connection();
$redis->publish('message', "fgfgff");
error
ConnectionException in AbstractConnection.php line 155:
No connection could be made because the target machine actively refused it. [tcp://127.0.0.1:6379]
If you are trying to create a connection between 2 host Redis is not an answer for you.
check out this question about what is Redis:
What is Redis and what do I use it for?
The problem with the Connection is probably because of the URL sending to the client side socket constructor.
change : var socket = io('http://localhost');
to : var socket = io();
Here is a link on step by step guide to use socket.io:
search "use socket.io with laravel" in Google.
To use connection between 2 host with Laravel you should use a package as it is not in Laravel by default.
this package enables push notification between server and devices like android or ios phones. here is the link to the package in GitHub:
davibennun/laravel-push-notification
Hope to be useful.
good luck.

Resources