Is it possible to communicate ionic android app and esp32 via Websocket with SSL? If yes, then how?

I have hosted websocket with ssl server on esp32 and ionic android app is my client. It works properly in computer, but it fails in android.
This is my client code.

const socket = new WebSocket("wss://server_ip:443/chat");

  socket.onopen = function (e) {
    console.log("[open] Connection established");
    setInterval(() => {
      console.log("Sending to server");
    }, 5000);

  socket.onmessage = function (event: any) {
    console.log(`[message] Data received from server: ${}`);

  socket.onclose = function (event: any) {
    if (event.wasClean) {
        `[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`
    } else {
      console.log("[close] Connection died");

  socket.onerror = function (error: any) {
    console.log(`[error] ${error}`);

Error: WebSocket connection to ‘wss://server_ip:443/chat’ failed: WebSocket opening handshake was canceled

Source: Ask Javascript Questions