Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection Refused on Android #47

Open
ChenSheng233 opened this issue Jan 16, 2019 · 0 comments
Open

Connection Refused on Android #47

ChenSheng233 opened this issue Jan 16, 2019 · 0 comments

Comments

@ChenSheng233
Copy link

    document.addEventListener("deviceready", function () {
        var socket = new Socket();
        socket.onData = receiveData;
        socket.onError = function (errorMessage) {
            alert("Error occured, error: " + errorMessage);
        };
        socket.onClose = function (hasError) {
            console.info("Socket closed, hasErrors=" + hasError);
            setDisconnected();
        };
        socket.open(
            "130a8d8b.all123.net",
            10086,
            setConnected,
            function (errorMessage) {
                alert("Error during connection, error: " + errorMessage);
            });

        function setConnected() {
            var menuEl = document.getElementById("menu");
            menuEl.style.display = "none";
            var consoleEl = document.getElementById("console");
            consoleEl.style.display = "block";
        }

        function receiveData(data) {
            var chars = new Array(data.length);
            for (var i = 0; i < data.length; i++) {
                chars.push(String.fromCharCode(data[i]));
            }
            var dataString = chars.join("");
            dataString.split(/(?:\r\n|\r|\n)/g).forEach(addTextToOutputElement);
        }
    })

config.xml

  <?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloWorld</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <plugin name="cz.blocshop.socketsforcordova" spec="^1.1.0" />
    <engine name="android" spec="7.1.4" />
</widget>

I got
failed to connect to 130a8d8b.all123.net/127.10.141.140 (port 10086): connect failed: ECONNREFUSED (Connection refused)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant