emailjs/emailjs-tcp-socket

Chrome legacy socket API obsolete?

danaki opened this issue · 3 comments

Getting this error:

Error in response to runtime.getPlatformInfo: TypeError: Cannot read property 'create' of undefined
    at TCPSocket._createLegacySocket (chrome-extension://jjhfjlndikmcdkjlkkomnfelhlbkefmc/node_modules/tcp-socket/src/tcp-socket.js:455:26)
    at Object.callback (chrome-extension://jjhfjlndikmcdkjlkkomnfelhlbkefmc/node_modules/tcp-socket/src/tcp-socket.js:442:26)
    at new TCPSocket (chrome-extension://jjhfjlndikmcdkjlkkomnfelhlbkefmc/node_modules/tcp-socket/src/tcp-socket.js:418:28)
    at Function.TCPSocket.open (chrome-extension://jjhfjlndikmcdkjlkkomnfelhlbkefmc/node_modules/tcp-socket/src/tcp-socket.js:898:16)
    at chrome-extension://jjhfjlndikmcdkjlkkomnfelhlbkefmc/bin/main.js:5:31
    at chrome-extension://jjhfjlndikmcdkjlkkomnfelhlbkefmc/bin/main.js:13:4

Seems this check in chromeShim() forces obsolete API which is unavailable in recent versions:

                if (platformInfo.os.indexOf("cordova") !== -1) {
                    // chrome.sockets.tcp.secure is not functional on cordova
                    // https://github.com/MobileChromeApps/mobile-chrome-apps/issues/269
                    self._useLegacySocket = false;
                    self._useForgeTls = true;
                } else {
                    self._useLegacySocket = true;
                    self._useForgeTls = false;
                }

platformInfo.os.indexOf("cordova") for "mac" gives -1 which sets self._useLegacySocket = true in else block.

Chrome Version 47.0.2526.106 (64-bit)

Please fix

Well, shit. This API was deprecated since chrome 33, but it was the only one that actually worked. AFAIK, chrome.sockets.tcp.secure still has not been fixed. Word on the street is that Google will deprecate Chrome apps sooner or later anyway... Hoped they'd never actually go through with removing it without fixing the other API first.

This means we can remove the legacy socket code branch 👍 , but we also lose native TLS for STARTTLS 👎

Nope, just checked: Still works in M47! Please make sure you use the right permissions in your manifest.json!

Use this:

    "permissions": [{
        "socket": ["tcp-connect"]
    }],

Instead of this:

    "sockets": {
        "tcp": {
            "connect": ""
        }
    },

It appears the "socket" permission as shown in the previous post now only works for apps, instead of extensions. (it used to work for extensions, as seen here: http://chromespot.com/2012/11/15/chromes-tcpudp-socket-support-benefits-and-its-dangers)

Nowadays, one gets this error when attempting to add either the "socket" permission or the newer "sockets" functionality to an extension:

It's a shame as it (would have been) the only way to use UDP sockets in extensions. Since apps are being phased out, it means we have no way to use UDP sockets without having users download a native app that connects to our extensions. :/