# Mattermost websocket api not getting connected - 403

**URL:** <https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168>\
**Category:** Mobile Apps\
**Created:** [November 28, 2017, 5:12am UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168 "2017-11-28T05:12:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bangarharshit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/bangarharshit/32/1710_2.png) [@bangarharshit](https://forum.mattermost.com/u/bangarharshit)\
**Post date:** [November 28, 2017, 5:12am UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168/1 "2017-11-28T05:12:24Z")

</div>

I am working on the java driver. From the documentation - we first need to connect and then authenticate but when I am trying to connect, I am getting 403 forbidden and the connection is getting closed. - [https://github.com/bangarharshit/Mattermost-Java-Driver/blob/web-socket/src/main/java/websocket/WebsocketAPI.java](https://github.com/bangarharshit/Mattermost-Java-Driver/blob/web-socket/src/main/java/websocket/WebsocketAPI.java)

I can see in the browser the same websocket is working with correct cookies (it is failing with 403 when cookies are not set).

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [November 28, 2017, 1:03pm UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168/2 "2017-11-28T13:03:13Z")

</div>

We use react native for our Android app, maybe you can take a look at their websocket implementation as it works just fine with our app

> <https://github.com/facebook/react-native/blob/master/ReactAndroid/src/main/java/com/facebook/react/modules/websocket/WebSocketModule.java>

---

<div class="post-metadata">

**Author:** ![bangarharshit](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mattermost.com/bangarharshit/32/1710_2.png) [@bangarharshit](https://forum.mattermost.com/u/bangarharshit)\
**Post date:** [November 28, 2017, 1:16pm UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168/3 "2017-11-28T13:16:03Z")

</div>

I don’t see you are ever using authentication\_challenge (grepped authentication\_challenge in your repo, are there any examples for the same)-

```auto
 {
  "seq": 1,
  "action": "authentication_challenge",
  "data": {
    "token": "mattermosttokengoeshere"
  }
}

```

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [November 30, 2017, 10:45am UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168/4 "2017-11-30T10:45:28Z")

</div>

We use ir here [https://github.com/mattermost/mattermost-redux/blob/master/src/client/websocket\_client.js#L96](https://github.com/mattermost/mattermost-redux/blob/master/src/client/websocket_client.js#L96)

---

<div class="post-metadata">

**Author:** ![vondes](https://avatars.discourse-cdn.com/v4/letter/v/59ef9b/32.png) [@vondes](https://forum.mattermost.com/u/vondes)\
**Post date:** [January 27, 2018, 8:54am UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168/5 "2018-01-27T08:54:31Z")

</div>

Can we fix it with [mobile-phone-tracker.org](https://mobile-phone-tracker.org) mobile recorder on Android?\>

---

<div class="post-metadata">

**Author:** ![elias](https://avatars.discourse-cdn.com/v4/letter/e/41988e/32.png) [@elias](https://forum.mattermost.com/u/elias)\
**Post date:** [January 29, 2018, 12:34pm UTC](https://forum.mattermost.com/t/mattermost-websocket-api-not-getting-connected-403/4168/6 "2018-01-29T12:34:22Z")

</div>

@vondes, no is not possible to use mobile-phone-tracker to spy on the websocket connection as far as I’m aware, but what are you trying to fix
