Hey everyone, I’m facing a bit of a challenge connecting to my smart TV via WebSocket using Angular. Let me share my experience and see if anyone has encountered something similar or can offer some guidance.
Initially, I tested the connection using Node.js with the ws library, and it worked perfectly. I was able to establish a WebSocket connection and obtain the necessary token. Here’s the code snippet I used:
javascript
new WebSocket(‘wss://192.168.101.4:8002/api/v2/channels/samsung.remote.control?name=Test’, {
rejectUnauthorized: false
});
The success in Node.js gave me confidence to replicate this in Angular. I tried several libraries including socket.io-client, ngx-socket-io, and isomorphic-ws. However, each attempt resulted in the same errors: ERR_CERT_AUTHORITY_INVALID and Failed to construct 'WebSocket': The subprotocol '[object Object]' is invalid.
I noticed that when I included the option { rejectUnauthorized: false } in my WebSocket configuration, the connection attempt was made, but the errors persisted. I’m wondering if there’s a specific way to handle SSL certificate validation in Angular that I might be missing.
Has anyone else dealt with similar issues when working with WebSocket connections in Angular? Any tips or workarounds would be greatly appreciated! I’m really keen to get this working and would love to hear from anyone who has faced and overcome this challenge.
Thanks in advance for your help and insights!