How to fix websocket error?

I did package source code and i set config.json AllowCorsFrom: “*” and execute and i tried to login

and then, login is sucess but, i got some error log for below…

the error is…

{“level”:“error”,“ts”:1533098193.6783123,“caller”:“api4/websocket.go:28”,“msg”:“websocket connect err: websocket: the client is not using the websocket protocol: ‘upgrade’ token not found in ‘Connection’ header”}

{“level”:“error”,“ts:1533098193.678331”,“caller”:“web/context.go:60”,“msg”:“Failed to upgrade websocket connection”,“path”:“/api/v4/websocket”,“request_id”:“j4kzz13t3bgntjxoh1tzq3bdea”,“ip_addr”:“40.10.33.40”,“user_id”:“uab87w37winybeshtwyh6n3o3a”,“method”:“GET”,“err_where”:“connect”,“http_code”:500,“err_details”:“”}

also, we don’t use Nginx…

Can I have any help ?

Thanks.

Hi @bje! Thank you for reaching out.

Do you have reverse proxy configured with IIS? If yes, can you help check that you are using IIS 8.0 or later and have enabled WebSockets.

Thanks for replys @amy.blais

I don’t have reverse proxy configured with IIS

my config.json contents is

{
“ServiceSettings”: {
“SiteURL”: “”,
“WebsocketURL”: “”,
“LicenseFileLocation”: “”,
“ListenAddress”: “:8065”,
“ConnectionSecurity”: “”,
“TLSCertFile”: “”,
“TLSKeyFile”: “”,
“UseLetsEncrypt”: false,
“LetsEncryptCertificateCacheFile”: “./config/letsencrypt.cache”,
“Forward80To443”: false,
“ReadTimeout”: 300,
“WriteTimeout”: 300,
“MaximumLoginAttempts”: 10,
“GoroutineHealthThreshold”: -1,
“GoogleDeveloperKey”: “”,
“EnableOAuthServiceProvider”: false,
“EnableIncomingWebhooks”: true,
“EnableOutgoingWebhooks”: true,
“EnableCommands”: true,
“EnableOnlyAdminIntegrations”: true,
“EnablePostUsernameOverride”: false,
“EnablePostIconOverride”: false,
“EnableLinkPreviews”: false,
“EnableTesting”: false,
“EnableDeveloper”: true,
“EnableSecurityFixAlert”: true,
“EnableInsecureOutgoingConnections”: false,
“AllowedUntrustedInternalConnections”: “”,
“EnableMultifactorAuthentication”: false,
“EnforceMultifactorAuthentication”: false,
“EnableUserAccessTokens”: false,
“AllowCorsFrom”: “*”,
“AllowCookiesForSubdomains”: false,
“SessionLengthWebInDays”: 30,
“SessionLengthMobileInDays”: 30,
“SessionLengthSSOInDays”: 30,
“SessionCacheInMinutes”: 10,
“SessionIdleTimeoutInMinutes”: 0,
“WebsocketSecurePort”: 443,
“WebsocketPort”: 80,
“WebserverMode”: “gzip”,
“EnableCustomEmoji”: false,
“EnableEmojiPicker”: true,
“EnableGifPicker”: false,
“GfycatApiKey”: “2_KtH_W5”,
“GfycatApiSecret”: “3wLVZPiswc3DnaiaFoLkDvB4X0IV6CpMkj4tf2inJRsBY6-FnkT08zGmppWFgeof”,
“RestrictCustomEmojiCreation”: “all”,
“RestrictPostDelete”: “all”,
“AllowEditPost”: “always”,
“PostEditTimeLimit”: -1,
“TimeBetweenUserTypingUpdatesMilliseconds”: 5000,
“EnablePostSearch”: true,
“EnableUserTypingMessages”: true,
“EnableChannelViewedMessages”: true,
“EnableUserStatuses”: true,
“ExperimentalEnableAuthenticationTransfer”: true,
“ClusterLogTimeoutMilliseconds”: 2000,
“CloseUnusedDirectMessages”: false,
“EnablePreviewFeatures”: true,
“EnableTutorial”: true,
“ExperimentalEnableDefaultChannelLeaveJoinMessages”: true,
“ExperimentalGroupUnreadChannels”: “disabled”,
“ImageProxyType”: “”,
“ImageProxyURL”: “”,
“ImageProxyOptions”: “”,
“EnableAPITeamDeletion”: false,
“ExperimentalEnableHardenedMode”: false,
“ExperimentalLimitClientConfig”: false,
“EnableEmailInvitations”: false
},
“TeamSettings”: {
“SiteName”: “Mattermost”,
“MaxUsersPerTeam”: 50,
“EnableTeamCreation”: true,
“EnableUserCreation”: true,
“EnableOpenServer”: false,
“EnableUserDeactivation”: false,
“RestrictCreationToDomains”: “”,
“EnableCustomBrand”: false,
“CustomBrandText”: “”,
“CustomDescriptionText”: “”,
“RestrictDirectMessage”: “any”,
“RestrictTeamInvite”: “all”,
“RestrictPublicChannelManagement”: “all”,
“RestrictPrivateChannelManagement”: “all”,
“RestrictPublicChannelCreation”: “all”,
“RestrictPrivateChannelCreation”: “all”,
“RestrictPublicChannelDeletion”: “all”,
“RestrictPrivateChannelDeletion”: “all”,
“RestrictPrivateChannelManageMembers”: “all”,
“EnableXToLeaveChannelsFromLHS”: false,
“UserStatusAwayTimeout”: 300,
“MaxChannelsPerTeam”: 2000,
“MaxNotificationsPerChannel”: 1000,
“EnableConfirmNotificationsToChannel”: true,
“TeammateNameDisplay”: “username”,
“ExperimentalEnableAutomaticReplies”: false,
“ExperimentalHideTownSquareinLHS”: false,
“ExperimentalTownSquareIsReadOnly”: false,
“ExperimentalPrimaryTeam”: “”
},
“ClientRequirements”: {
“AndroidLatestVersion”: “”,
“AndroidMinVersion”: “”,
“DesktopLatestVersion”: “”,
“DesktopMinVersion”: “”,
“IosLatestVersion”: “”,
“IosMinVersion”: “”
},
“SqlSettings”: {
“DriverName”: “postgres”,
“DataSource”: “postgres://mmuser:mmuser@192.168.15.100:5432/mattermost01?sslmode=disable\u0026connect_timeout=10”,
“DataSourceReplicas”: ,
“DataSourceSearchReplicas”: ,
“MaxIdleConns”: 20,
“ConnMaxLifetimeMilliseconds”: 3600000,
“MaxOpenConns”: 300,
“Trace”: false,
“AtRestEncryptKey”: “kto5nxqzescipjo9awdon8u8469b9ong”,
“QueryTimeout”: 30
},
“LogSettings”: {
“EnableConsole”: true,
“ConsoleLevel”: “DEBUG”,
“ConsoleJson”: true,
“EnableFile”: true,
“FileLevel”: “INFO”,
“FileJson”: true,
“FileLocation”: “”,
“EnableWebhookDebugging”: true,
“EnableDiagnostics”: true
},
“PasswordSettings”: {
“MinimumLength”: 5,
“Lowercase”: false,
“Number”: false,
“Uppercase”: false,
“Symbol”: false
},
“FileSettings”: {
“EnableFileAttachments”: true,
“EnableMobileUpload”: true,
“EnableMobileDownload”: true,
“MaxFileSize”: 52428800,
“DriverName”: “local”,
“Directory”: “./data/”,
“EnablePublicLink”: false,
“PublicLinkSalt”: “ugy1yu8j5fk1frb4djmdsyadjwc1roum”,
“InitialFont”: “nunito-bold.ttf”,
“AmazonS3AccessKeyId”: “”,
“AmazonS3SecretAccessKey”: “”,
“AmazonS3Bucket”: “”,
“AmazonS3Region”: “”,
“AmazonS3Endpoint”: “s3.amazonaws.com”,
“AmazonS3SSL”: true,
“AmazonS3SignV2”: false,
“AmazonS3SSE”: false,
“AmazonS3Trace”: false
},
“EmailSettings”: {
“EnableSignUpWithEmail”: true,
“EnableSignInWithEmail”: true,
“EnableSignInWithUsername”: true,
“SendEmailNotifications”: true,
“UseChannelInEmailNotifications”: false,
“RequireEmailVerification”: false,
“FeedbackName”: “”,
“FeedbackEmail”: “test@example.com”,
“FeedbackOrganization”: “”,
“EnableSMTPAuth”: false,
“SMTPUsername”: “”,
“SMTPPassword”: “”,
“SMTPServer”: “dockerhost”,
“SMTPPort”: “2500”,
“ConnectionSecurity”: “”,
“InviteSalt”: “yon54zupue7eew4z5ocruo7x1bj9k9of”,
“SendPushNotifications”: false,
“PushNotificationServer”: “”,
“PushNotificationContents”: “generic”,
“EnableEmailBatching”: false,
“EmailBatchingBufferSize”: 256,
“EmailBatchingInterval”: 30,
“EnablePreviewModeBanner”: true,
“SkipServerCertificateVerification”: false,
“EmailNotificationContentsType”: “full”,
“LoginButtonColor”: “”,
“LoginButtonBorderColor”: “”,
“LoginButtonTextColor”: “”
},
“RateLimitSettings”: {
“Enable”: false,
“PerSec”: 10,
“MaxBurst”: 100,
“MemoryStoreSize”: 10000,
“VaryByRemoteAddr”: true,
“VaryByUser”: false,
“VaryByHeader”: “”
},
“PrivacySettings”: {
“ShowEmailAddress”: true,
“ShowFullName”: true
},
“SupportSettings”: {
“TermsOfServiceLink”: “Terms of Use - Mattermost Open Source Collaboration Platform”,
“PrivacyPolicyLink”: “Mattermost Privacy Policy - Open Source Messaging”,
“AboutLink”: “Mattermost overview — Mattermost documentation”,
“HelpLink”: “Homepage | Mattermost Academy”,
“ReportAProblemLink”: “How to contribute to Mattermost - Mattermost Handbook”,
“SupportEmail”: “feedback@mattermost.com
},
“AnnouncementSettings”: {
“EnableBanner”: false,
“BannerText”: “”,
“BannerColor”: “#f2a93b”,
“BannerTextColor”: “#333333”,
“AllowBannerDismissal”: true
},
“ThemeSettings”: {
“EnableThemeSelection”: true,
“DefaultTheme”: “default”,
“AllowCustomThemes”: true,
“AllowedThemes”:
},
“GitLabSettings”: {
“Enable”: false,
“Secret”: “”,
“Id”: “”,
“Scope”: “”,
“AuthEndpoint”: “”,
“TokenEndpoint”: “”,
“UserApiEndpoint”: “”
},
“GoogleSettings”: {
“Enable”: false,
“Secret”: “”,
“Id”: “”,
“Scope”: “profile email”,
“AuthEndpoint”: “Sign in - Google Accounts”,
“TokenEndpoint”: “https://www.googleapis.com/oauth2/v4/token”,
“UserApiEndpoint”: “https://www.googleapis.com/plus/v1/people/me
},
“Office365Settings”: {
“Enable”: false,
“Secret”: “”,
“Id”: “”,
“Scope”: “User.Read”,
“AuthEndpoint”: “Sign in to your account”,
“TokenEndpoint”: “Sign in to your account”,
“UserApiEndpoint”: “https://graph.microsoft.com/v1.0/me
},
“LdapSettings”: {
“Enable”: false,
“EnableSync”: false,
“LdapServer”: “”,
“LdapPort”: 389,
“ConnectionSecurity”: “”,
“BaseDN”: “”,
“BindUsername”: “”,
“BindPassword”: “”,
“UserFilter”: “”,
“FirstNameAttribute”: “”,
“LastNameAttribute”: “”,
“EmailAttribute”: “”,
“UsernameAttribute”: “”,
“NicknameAttribute”: “”,
“IdAttribute”: “”,
“PositionAttribute”: “”,
“LoginIdAttribute”: “”,
“SyncIntervalMinutes”: 60,
“SkipCertificateVerification”: false,
“QueryTimeout”: 60,
“MaxPageSize”: 0,
“LoginFieldName”: “”,
“LoginButtonColor”: “”,
“LoginButtonBorderColor”: “”,
“LoginButtonTextColor”: “”
},
“ComplianceSettings”: {
“Enable”: false,
“Directory”: “./data/”,
“EnableDaily”: false
},
“LocalizationSettings”: {
“DefaultServerLocale”: “en”,
“DefaultClientLocale”: “en”,
“AvailableLocales”: “”
},
“SamlSettings”: {
“Enable”: false,
“EnableSyncWithLdap”: false,
“Verify”: true,
“Encrypt”: true,
“IdpUrl”: “”,
“IdpDescriptorUrl”: “”,
“AssertionConsumerServiceURL”: “”,
“ScopingIDPProviderId”: “”,
“ScopingIDPName”: “”,
“IdpCertificateFile”: “”,
“PublicCertificateFile”: “”,
“PrivateKeyFile”: “”,
“FirstNameAttribute”: “”,
“LastNameAttribute”: “”,
“EmailAttribute”: “”,
“UsernameAttribute”: “”,
“NicknameAttribute”: “”,
“LocaleAttribute”: “”,
“PositionAttribute”: “”,
“LoginButtonText”: “With SAML”,
“LoginButtonColor”: “”,
“LoginButtonBorderColor”: “”,
“LoginButtonTextColor”: “”
},
“NativeAppSettings”: {
“AppDownloadLink”: “Host Mattermost on Your Own Infrastructure”,
“AndroidAppDownloadLink”: “https://about.mattermost.com/mattermost-android-app/”,
“IosAppDownloadLink”: “‎Mattermost on the App Store
},
“ClusterSettings”: {
“Enable”: false,
“ClusterName”: “”,
“OverrideHostname”: “”,
“UseIpAddress”: true,
“UseExperimentalGossip”: false,
“ReadOnlyConfig”: true,
“GossipPort”: 8074,
“StreamingPort”: 8075,
“MaxIdleConns”: 100,
“MaxIdleConnsPerHost”: 128,
“IdleConnTimeoutMilliseconds”: 90000
},
“MetricsSettings”: {
“Enable”: false,
“BlockProfileRate”: 0,
“ListenAddress”: “:8067”
},
“ExperimentalSettings”: {
“ClientSideCertEnable”: false,
“ClientSideCertCheck”: “secondary”
},
“AnalyticsSettings”: {
“MaxUsersForStatistics”: 2500
},
“WebrtcSettings”: {
“Enable”: false,
“GatewayWebsocketUrl”: “”,
“GatewayAdminUrl”: “”,
“GatewayAdminSecret”: “”,
“StunURI”: “”,
“TurnURI”: “”,
“TurnUsername”: “”,
“TurnSharedKey”: “”
},
“ElasticsearchSettings”: {
“ConnectionUrl”: “http://dockerhost:9200”,
“Username”: “elastic”,
“Password”: “changeme”,
“EnableIndexing”: false,
“EnableSearching”: false,
“Sniff”: true,
“PostIndexReplicas”: 1,
“PostIndexShards”: 1,
“AggregatePostsAfterDays”: 365,
“PostsAggregatorJobStartTime”: “03:00”,
“IndexPrefix”: “”,
“LiveIndexingBatchSize”: 1,
“BulkIndexingTimeWindowSeconds”: 3600,
“RequestTimeoutSeconds”: 30
},
“DataRetentionSettings”: {
“EnableMessageDeletion”: false,
“EnableFileDeletion”: false,
“MessageRetentionDays”: 365,
“FileRetentionDays”: 365,
“DeletionJobStartTime”: “02:00”
},
“MessageExportSettings”: {
“EnableExport”: false,
“ExportFormat”: “actiance”,
“DailyRunTime”: “01:00”,
“ExportFromTimestamp”: 0,
“BatchSize”: 10000,
“GlobalRelaySettings”: {
“CustomerType”: “A9”,
“SmtpUsername”: “”,
“SmtpPassword”: “”,
“EmailAddress”: “”
}
},
“JobSettings”: {
“RunJobs”: true,
“RunScheduler”: true
},
“PluginSettings”: {
“Enable”: true,
“EnableUploads”: false,
“Directory”: “./plugins”,
“ClientDirectory”: “./client/plugins”,
“Plugins”: {},
“PluginStates”: {}
},
“DisplaySettings”: {
“CustomUrlSchemes”: ,
“ExperimentalTimezone”: false
},
“TimezoneSettings”: {
“SupportedTimezonesPath”: “timezones.json”
}
}

and my config.json file websocket is

“ServiceSettings”: {
“WebsocketURL”: “”,
“WebsocketSecurePort”: 443,
“WebsocketPort”: 80,
“AllowCorsFrom”: “*”,
}

so, what should i do if i want to fix it?
and should i hava to set Nginx or IIS?

Hi @bje Giving you an update that I have asked our developers about this and I’ll let you know as soon as I get feedback.

Hi @bje - What browser are you using? Or are you using the desktop app?

Thanks for replys @amy.blais

I just use browser for Windows Explorer or Chrome.

And my Mattermost version is 5.1

If anyone know how to fix this issue, let me help.

I tried to configured…

“WebsocketURL”: “ws://ip_address:8065”,

then, i get some error log like “closing websocket” or “websocket connect and websocket closed”

and then, I tried other configured…

“WebsocketURL”: “ws:/localhost:8065”,

also, I get “websocket error”

If i tried “WebsocketURL” value like “”,

i get some error log in browser developer tool is below…

aaaa

Hi @bje - I checked with engineers about this and I’ll summarize their questions / responses here:

  1. One thing they can think of is that the siteURL is not set.

  2. Also, they are wondering why the config.json says you are using port 8065 but the above screenshot says 8080?

  3. There is a 500 (Internal Server Error) in your console logs - would you be able to help with your server logs as well?

1 Like

Thanks for answer @amy.blais

well… I give you more information for my errors

the info is…

  1. my server error log is “Failed to upgrade websocket connection” and “websocket.authTicker: did not authenticate ip=xxxxx”. but i already log in Mattermost and tokens are already set for browser. so, i don’t know why…

  2. my browser error is “/api/v4/websocket’ failed: Error during WebSocket handshake”

  3. if i use nginx, browser show me “too many redirect” message

thanks for your kindness :slight_smile:

Summary of issue:

bje set config.json AllowCorsFrom: “*” and was able to log in but sees these errors:

  1. Server error log: “Failed to upgrade websocket connection” and “websocket.authTicker: did not authenticate ip=xxxxx”. They are logged in to Mattermost and tokens are already set for browser.

  2. Browser error: “/api/v4/websocket’ failed: Error during WebSocket handshake”

  3. If they use nginx, browser shows “too many redirects” message.

They normally don’t use Nginx and their websocket config settings are below with a full list of other config settings here:

“ServiceSettings”: {
“WebsocketURL”: “”,
“WebsocketSecurePort”: 443,
“WebsocketPort”: 80,
“AllowCorsFrom”: “*”, }

Thanks for replys @amy.blais

Today i tried to test for Mattermost Websocket…

I modified SiteURL like http://mm.domain.com and WebsocketURL like ws://mm.domain.com:8065

so, today i saw debug log like below…

websocket.authTicker: did not authenticate ip=xxxxxx:24370

websocket.read: closing websocket for userId= error=read tcp 40.1.4.19:8065->40.60.191.122:56424: use of closed network connection

and i saw a lot of “websocket closed” and “websocket re-established” in browser console

Thanks

Hi @bje,

Under normal circumstances, you shouldn’t need to specify WebsocketURL because the browser will get it from the web page automatically. Since you’ve now specified a SiteURL, maybe try removing the WebsocketURL?

1 Like