Websockets posted messages not coming to client

Hello all.

In our angular app we have a wss connection to the websocket on the server. We are seeing user status notices, server hellos, new channels, but the posted messages are not coming … which are kinda the most important …

DOes anyone have any suggestions?

Thank you.

KG

Hi @keithg - it sounds like you’re websocket isn’t connecting properly.

Can you try:

  1. Checking the websocket connection
  2. If you have SSL set up, also check the SSL certificate is set up properly (step 8 in set up guide)

If you’re still having issues, can you check the logs and post any errors you see?

lfbrock

THank you for the reply. The option 1 in your post might be my issue. It shows as pending … but I still receive user status_update messages and server. This is my nginx config …

server {
listen 80;
server_name chat.domain.com;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl;
server_name chat.mydomain.com;

more_set_headers 'Access-Control-Allow-Origin: *';
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, HEAD';
more_set_headers 'Access-Control-Expose-Headers:  Token';
more_set_headers 'Access-Control-Allow-Headers: Origin,Content-Type,Accept,Authorization';

ssl on;

ssl_certificate /etc/letsencrypt/live/chat.mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/chat.mydomain.com/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ‘EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH’;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

location / {
gzip off;
proxy_set_header X-Forwarded-Ssl on;
client_max_body_size 50M;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection “upgrade”;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_pass http://45.33.XX.XX:8065;

    if ($request_method = 'OPTIONS') {
        more_set_headers 'Access-Control-Allow-Origin: *';
        more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, HEAD';
        more_set_headers 'Access-Control-Max-Age: 1728000';
        more_set_headers 'Access-Control-Allow-Credentials: true';
        more_set_headers 'Access-Control-Allow-Headers: Origin,Content-Type,Accept,Authorization';
        more_set_headers 'Access-Control-Expose-Headers:  Token';
        more_set_headers 'Content-Type: text/plain; charset=UTF-8';
        more_set_headers 'Content-Length: 0';
        return 204;
    }

} indent preformatted text by 4 spaces

location /api/v3/users/websocket {
    proxy_set_header X-Forwarded-Ssl on;
    proxy_pass http://45.33.XX.XX:8065;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    more_set_headers 'Access-Control-Allow-Origin: *';
more_set_headers 'Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE, HEAD';
more_set_headers 'Access-Control-Expose-Headers:  Token';
more_set_headers 'Access-Control-Allow-Headers: Origin,Content-Type,Accept,Authorization';
}
client_max_body_size 4G;
keepalive_timeout 10;

} indent preformatted text by 4 spaces

In the Solution:

Follow the installation guide to set up your WebSocket port properly. (https://docs.mattermost.com/install/prod-ubuntu.html#set-up-nginx-server)
Speak with the owner of any other proxies between your device and the Mattermost server to ensure wss connections are passing through without issue.

But there is no information about the particulars of the websocket connection. Is there a special port? Something I am missing?

You can see I am getting a response from the server. This would not be coming if there was no connecting?

It just wont send the posted messages. Very frustrating …

Hello…

How exactly should I be authenticating the websocket with the MM server? I am using the api and have a custom implementation of chat inside our angular app. I login the user inside the app and the use the token provided in there to generate the Bearer header for authenticating with the API. I have also been using that same authentication token for the websocket. Should I be passing the token as a get variable instead to the websocket?

Anything you can suggest would be greatly helpful.

Thsank you.

I have adjusted the nginx and now I am seeing the following in the MM Logs …
websocket connect err: websocket: could not find connection header with token ‘upgrade’

I reverted my nginx setting back to what i copied above and the connection is working … i am receiving messages from the server … see capture below … showing new user and user status … but the websocket is not broadcasting new channel messages or new post messages … is there something I need to toggle on the server?

Hi @keithg,

Is the user you’re logged in as in the channels you would like to receive messages for? If not, the WebSocket will not broadcast new post events to your WS connection