douduiwei2831 2018-10-22 08:05
浏览 73

棘轮+ AWS EC2 + SSL + ProxyPass - >无效的状态行

I'm trying to create a video chat using ratchet with laravel and it worked fine on localhost but when I deployed it on an EC2 instance, it needed some configuration. First, I can access my app with HTTPS, it works fine. I can connect to my Ratchet WebSocket server via ws and HTTP but HTTPS requires wss and I can't figure out how to make it work. I've used ProxyPass since it seems to be the answer for most people : (etc/httpd/conf.d/ssl.conf)

ProxyPass /wss2/ ws://fake-domain.us-east-2.elasticbeanstalk.com:8181/

And my client side JS code : var socket = new WebSocket('wss://fake-domain.us-east-2.elasticbeanstalk.com/wss2/');

But this returns : 'Error during WebSocket handshake: Invalid status line' and it doesn't even change anything if I run my Ratchet server or not.

PHP code (I managed to put it in a laravel command so it's easier):

public function handle()
    {
        $server = IoServer::factory(
            new WsServer(
                new VideoController()
            ),
            8181
        );

        $server->run();
    }

I can telnet fake-domain.us-east-2.elasticbeanstalk.com 8181, it says it works. I saw that it could come from the apache version so I updated my apache and php version : php -v = 7.2.8 httpd -v = 2.4.34 I accept all traffic in the security groups and port 80, 443 and 8181 are open.

What am I missing? Thank's ;)

UPDATE : I figured out that I wasn't starting the socket server correctly, I forgot to put "sudo" before my command, but now it gives me another error:

UnexpectedValueException  : $request can not be null

  at /var/app/current/vendor/cboden/ratchet/src/Ratchet/WebSocket/WsServer.php:109
    105|      * {@inheritdoc}
    106|      */
    107|     public function onOpen(ConnectionInterface $conn, RequestInterface $request = null) {
    108|         if (null === $request) {
  > 109|             throw new \UnexpectedValueException('$request can not be null');
    110|         }
    111|
    112|         $conn->httpRequest = $request;
    113|

UPDATE 2 :

I think I've just found the solution, I think I didn't integrate Ratchet correctly with Laravel and maybe the solution is here : https://gist.github.com/Mevrael/6855dd47d45fa34ee7161c8e0d2d0e88 I'm going to try tomorrow

  • 写回答

1条回答 默认 最新

  • douliu8327 2018-10-23 07:51
    关注

    I've finnaly found how to make it work!! It was just an error in the load balancer, the port 8181 was SSL and when I changed to TCP it worked!!

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line