WebSocket with Nginx

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dimyy
    Active Community Member
    • Jun 2018
    • 569

    WebSocket with Nginx

    Problem: By default NGINX closes the connection if no data is sent for 60 seconds.
    Doc: This timeout value can be changed wth proxy_read_timeout; alternatively, a WebSocket server should send ping messages periodically to reset the timer, but

    The problem is partially solved by setting proxy_read_timeout 43200 (12 hours), but

    1. Server don't send ping messages
    2. After a connection failure (trouble with inet connection, restart nginx etc), it is no longer restored until client reload
    Attached Files
  • yuri
    Member
    • Mar 2014
    • 8440

    #2
    Unfortunately, I'm not able to help with this problem at this moment. If you find a solution please let me know. I believe that increasing proxy_read_timeout should be enough.

    I don't think that we should ping from the websocket server. Our websocket server doesn't know about the existence of the proxy.

    > it is no longer restored until client reload

    Do you mean browser page re-loading?
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • dimyy
      Active Community Member
      • Jun 2018
      • 569

      #3
      Originally posted by yurikuzn
      Unfortunately, I'm not able to help with this problem at this moment. If you find a solution please let me know. I believe that increasing proxy_read_timeout should be enough.

      I don't think that we should ping from the websocket server. Our websocket server doesn't know about the existence of the proxy.

      > it is no longer restored until client reload

      Do you mean browser page re-loading?
      Yes. Browser page don't don't restore connection if it lost

      I think you need to add option "proxy_read_timeout 86400;" in nginx config section.
      Last edited by dimyy; 04-15-2020, 04:14 PM.

      Comment

      • dimyy
        Active Community Member
        • Jun 2018
        • 569

        #4
        Two days testing.
        Timeout don't solve problem. Server don't break the connection, but connection breaks several times a day (without any pattern) and Client (web-page) don't restore connection.
        Another problem - bell with unread messages don't updated.
        Attached Files

        Comment

        • dimyy
          Active Community Member
          • Jun 2018
          • 569

          #5
          Another two days testing.

          Unfortunately, websocket option has very limited use if connection loss is not handled.
          Attached Files

          Comment

          • yuri
            Member
            • Mar 2014
            • 8440

            #6
            We've been using it quite a while and never felt that it is kind of "very" limited.
            Last edited by yuri; 04-21-2020, 10:34 AM.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            • dimyy
              Active Community Member
              • Jun 2018
              • 569

              #7
              Simple solution; add to https://github.com/espocrm/espocrm/b...manager.js#L98
              Code:
              location.reload();
              It's not good solution but simple.


              And another question: why use oldest version of autobahn? New versions have autoreconnect options

              Comment

              • yuri
                Member
                • Mar 2014
                • 8440

                #8
                Did you try to update to the newer version with the option enabled? It would save my time. I have too much of work.
                If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                Comment

                • dimyy
                  Active Community Member
                  • Jun 2018
                  • 569

                  #9
                  It's not necessary to update lib. We made some fixes to reconnect and re-subscribe. 3 weeks tests - all ok
                  Attached Files

                  Comment

                  • yuri
                    Member
                    • Mar 2014
                    • 8440

                    #10
                    I made changes based on your file: https://github.com/espocrm/espocrm/c...ee83d1e090e150

                    Please let me know if I missed something.
                    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

                    Comment


                    • dimyy
                      dimyy commented
                      Editing a comment
                      Looks like everything is ok
                  • Ananya K
                    Member
                    • Jul 2020
                    • 50

                    #11
                    I am facing some issues with this espo WebSocket.

                    We used the same file that is provided over here with Espocrm version 5.8.2 and 6.0.9.

                    The connection is lost every minute and the subscribeQueue will be reset. Because of that, we are getting the following error almost all the time.
                    Code:
                    VM5260:149 WebSocket: Could not unsubscribe from <category>.
                    Can anyone provide any solution to this problem?

                    Comment

                    • Ananya K
                      Member
                      • Jul 2020
                      • 50

                      #12
                      Hey,

                      Here is the file that I am using.

                      The ping is working fine. Still, in the console, I am getting the following error.

                      Code:
                      VM19385:104 Uncaught TypeError: Cannot read property 'send' of null
                      Updates

                      I wanted to mention that our Espocrm is completely running on docker with 3 different containers.
                      • BGT
                      • Socket
                      • App
                      When we bring up the socket container we will run the PHP script websocket.php.

                      The socket will keep on reconnect and the reconnect timing is not constant. It is not predictatble.

                      Can anyone please help me with this? If u need additional detail let me know.
                      Attached Files
                      Last edited by Ananya K; 05-05-2021, 12:03 PM.

                      Comment

                      Working...