Unable to connect websocket into service-workers

Viewed 2797

Wants to implement background push notififications even when the application browser window is closed, to achieve this i am using service-worker and websocket,unable to use websocket in service worker file.

// in serviceworker.js file

       const webSocket = new WebSocket(`ws://local_host/socket`);
       console.log(webSocket);

//Got following error

  Uncaught DOMException: Failed to construct 'WebSocket': The 
  subprotocol '[object Object]' is invalid.

Please help regarding this issue.

1 Answers
Related