When I build -prod, ws:// will become wss:// , and it's not working?

Hi all
In websocket
(@wahr/capacitor-websocket-client)

When the webapp in ionic7 and just use ionic serve,

It’s working and I see the connection is ws://xxxx.com

But when I use “ionic build -prod”, the websocket will change to use wss://xxxx.com, and it’s not working…

Anyone can help me to fix it??
Please :man_bowing:t2:

You need to share some code. What does your WebSocket.connect look like?

Looking at the source code, it would appear the web logic is using the built-in WebSocket API. I don’t see the plugin doing anything with the connection type.

As a note, you will want to use wss in production so your connections are encrypted.

@twestrick

Thanks for your reply,
I find the way now,

I use “ws://xxx.com:port” in my local computer and server before, in localhost, everything is ok, but in the server , all will change to https / wss, It’s not working…

but when I delete the port number, just use “ws://xxx.com” or “wss://xxx.com” , everything is working now :laughing:

1 Like