Legacy Dev Forum Posts

 View Only

Sign Up

Notifications websocket - Error 401

  • 1.  Notifications websocket - Error 401

    Posted 06-05-2025 18:16

    Adrian_Santamaria | 2020-02-05 09:45:12 UTC | #1

    Hello

    I wanted to do some testing with the notifications feature. I have created a channel using the API, and also suscribed to some topics.

    However, when I try to connect to the wss uri (using 'wcat', in cmd), I get a 401 error:

    wscat -c {{mywssuri}} error: Unexpected server response: 401

    What I am doing wrong? Do I have to include the token somewhere?

    Thank you


    tim.smith | 2020-02-05 16:14:26 UTC | #2

    I'm not sure why you'd be getting a 401; websocket connections do not require authentication. I'd suggest reviewing the documentation to make sure you're using the correct information: https://developer.mypurecloud.com/api/rest/v2/notifications/notification_service.html

    Also, the Developer Tools Notification Tester is a good way to test notifications without having to set up anything: https://developer.mypurecloud.com/developer-tools/#/notificationtester


    Adrian_Santamaria | 2020-02-05 16:37:54 UTC | #3

    Hello Tim

    I have used the API explorer tool to create the channel and suscribe to the topic. (POST /api/v2/notifications/channels and POST /api/v2/notifications/channels/{channelId}/subscriptions)

    After that, I have tried to connect to the wss URI obtained in the first request using wscat, but I get the 401 error.

    I have checked that is not my internet connection, because I am able to connect to a test one (wss://echo.websocket.org) without problems.


    tim.smith | 2020-02-05 18:38:35 UTC | #4

    Adrian_Santamaria, post:3, topic:7067
    I have used the API explorer tool to create the channel and suscribe to the topic. (POST /api/v2/notifications/channels and POST /api/v2/notifications/channels/{channelId}/subscriptions)

    After that, I have tried to connect to the wss URI obtained in the first request using wscat, but I get the 401 error.

    How long between those steps? You will only get a 401 if the channel itself has expired (24 hours after creation/update) or the auth token used to create the channel has expired.


    Adrian_Santamaria | 2020-02-06 06:57:18 UTC | #5

    Thank you Tim. It was the token, which had expired. Now it works.


    system | 2020-03-08 06:57:20 UTC | #6

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 7067