Mattermost-server: Websockets error doesn't come back in Firefox after dismissal

Created on 30 Sep 2015  路  10Comments  路  Source: mattermost/mattermost-server

If a websocket error occurs at it cannot reach the Mattermost server an error bar is displayed. This works correctly in Chrome and Firefox. However in Chrome if you dismiss it, it will come back the next time there is a connection error. In Firefox the error never comes back even if subsequent sessions (after hard page reloads) have connection issues at a later time.

1.0.0-RC1

Most helpful comment

@stephenfin Here's the main part. There is also a bit that catches HTTP and redirects to HTTPS, but this does all the heavy lifting. Note I'm serving up static resources directly from Apache.

<VirtualHost *:443>
    ServerName mattermost.alerque.com

    DocumentRoot /usr/share/webapps/mattermost/web

    SSLEngine on
    SSLCertificateFile    /etc/httpd/ssl.crt/alerque.com.crt
    SSLCertificateKeyFile /etc/httpd/ssl.key/alerque.com.key

    ProxyPreserveHost On

    RewriteEngine On

    RewriteCond %{REQUEST_URI}  ^/api/v1/websocket    [NC,OR]
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$           [NC,OR]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
    RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI}  [P,QSA,L]

    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
    RequestHeader set X-Forwarded-Proto "https"

    <Location /api/v1/websocket>
        Require all granted
        ProxyPassReverse ws://127.0.0.1:8065/api/vi/websocket
        ProxyPassReverseCookieDomain 127.0.0.1 mattermost.alerque.com
    </Location>

    <Location />
        Require all granted
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 mattermost.alerque.com
    </Location>

    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
    ErrorLog  /var/log/httpd/mattermost.alerque.com_error.log
    CustomLog /var/log/httpd/mattermost.alerque.com_forwarded.log common_forwarded
    CustomLog /var/log/httpd/mattermost.alerque.com_access.log combined env=!dontlog
    CustomLog /var/log/httpd/mattermost.alerque.com.log combined
</VirtualHost>

All 10 comments

thanks @alerque. I was able to repo this. The blue bar does return but it takes 30+ seconds.

@coreyhulen It took me at least 30 minutes to fix my Apache proxy to catch and properly forward the websocket requests. During that time I had both long running and constantly refreshing copies of the site open in both browsers on two platforms. On the FF ones I didn't see the message at all after the initial error. On the Chrome ones it would eventually come back if the error persisted or if I refreshed.

@alerque Would it be possible to share your Apache configuration? Alternatively, I have a HOWTO written on deploying the application on Ubuntu with Apache and perhaps if I submitted it as a PR you could review it for differences? I think I have my configuration mostly correct but I'm still seeing references to my instance's IP address instead of the hostname in things like the "Finding teams" emails. I'm blaming Apache until I know otherwise.

PR has been merged to master.

@stephenfin Here's the main part. There is also a bit that catches HTTP and redirects to HTTPS, but this does all the heavy lifting. Note I'm serving up static resources directly from Apache.

<VirtualHost *:443>
    ServerName mattermost.alerque.com

    DocumentRoot /usr/share/webapps/mattermost/web

    SSLEngine on
    SSLCertificateFile    /etc/httpd/ssl.crt/alerque.com.crt
    SSLCertificateKeyFile /etc/httpd/ssl.key/alerque.com.key

    ProxyPreserveHost On

    RewriteEngine On

    RewriteCond %{REQUEST_URI}  ^/api/v1/websocket    [NC,OR]
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$           [NC,OR]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$          [NC]
    RewriteRule .* ws://127.0.0.1:8065%{REQUEST_URI}  [P,QSA,L]

    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule .* http://127.0.0.1:8065%{REQUEST_URI} [P,QSA,L]
    RequestHeader set X-Forwarded-Proto "https"

    <Location /api/v1/websocket>
        Require all granted
        ProxyPassReverse ws://127.0.0.1:8065/api/vi/websocket
        ProxyPassReverseCookieDomain 127.0.0.1 mattermost.alerque.com
    </Location>

    <Location />
        Require all granted
        ProxyPassReverse http://127.0.0.1:8065/
        ProxyPassReverseCookieDomain 127.0.0.1 mattermost.alerque.com
    </Location>

    LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b" common_forwarded
    ErrorLog  /var/log/httpd/mattermost.alerque.com_error.log
    CustomLog /var/log/httpd/mattermost.alerque.com_forwarded.log common_forwarded
    CustomLog /var/log/httpd/mattermost.alerque.com_access.log combined env=!dontlog
    CustomLog /var/log/httpd/mattermost.alerque.com.log combined
</VirtualHost>

that conf worked for me...can it go into the documentation?

If you add this configuration to the documentation, take care to add the proxy_wstunnel module to apache :
http://forum.mattermost.org/t/solved-apache2-reverseproxy-with-websocket-https/437/5

Outstanding!

On websockets v4 I had to remove:

RequestHeader set X-Forwarded-Proto "https"

To get it to work.

Was this page helpful?
0 / 5 - 0 ratings