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

Can´t catch ERR_CONNECTION_REFUSED #1023

Closed
1 of 2 tasks
delike opened this issue Nov 14, 2016 · 8 comments
Closed
1 of 2 tasks

Can´t catch ERR_CONNECTION_REFUSED #1023

delike opened this issue Nov 14, 2016 · 8 comments

Comments

@delike
Copy link

delike commented Nov 14, 2016

  • report a bug
  • request a feature

Current behaviour

I cant catch the "ERR_CONNECTION_REFUSED" error when the socket connection is killed.

I have the following Event-Listener in my Code:

           this.socket.on('error', (err) => {
                console.log('Error connecting to server', err);
            });

            this.socket.on('disconnect', () => {
                console.log('Disconnect from server');
            });

            this.socket.on('reconnect', (number) => {
                console.log('Reconnected to server', number);
            });

            this.socket.on('reconnect_attempt', () => {
                console.log('Reconnect Attempt');
            });

            this.socket.on('reconnecting', (number) => {
                console.log('Reconnecting to server', number);
            });

            this.socket.on('reconnect_error', (err) => {
                console.log('Reconnect Error', err);
            });

            this.socket.on('reconnect_failed', () => {
                console.log('Reconnect failed');
            });

            this.socket.on('connect_error', () => {
                console.log('connect_error');
            });

and got this Error on Chrome console:

socket connected
socket.io.service.ts:69 Disconnect from server
socket.io.service.ts:83 Reconnect Attempt
socket.io.service.ts:90 Reconnecting to server 1
zone.js:1382 GET https://XXX:3000/socket.io/?auth_token=XXX&EIO=3&transport=polling&t=LXY2NwI net::ERR_CONNECTION_REFUSEDscheduleTask @ zone.js:1382ZoneDelegate.scheduleTask @ ...
socket.io.service.ts:111 connect_error
socket.io.service.ts:97 Reconnect Error Error: xhr poll error(…)
socket.io.service.ts:83 Reconnect Attempt
socket.io.service.ts:90 Reconnecting to server 2
...

Steps to reproduce (if the current behaviour is a bug)

Start a working app and stop the socket-server.

Setup

  • OS: macOS Sierra & Linux Debian Jessie
  • browser: Chrome
  • socket.io version: 1.5.1
@darrachequesne
Copy link
Member

Hi!

I cant catch the "ERR_CONNECTION_REFUSED" error when the socket connection is killed.

I don't understand... Aren't the events 'reconnect_error' and 'connect_error' properly emitted?

@bermanboris
Copy link

I have the same issue. Have you found any solution to this bug?

@xtremetom
Copy link

I have the exact same issue

@darrachequesne
Copy link
Member

@xtremetom @bermanboris

May I ask what behaviour you are expecting?

@herrmarten
Copy link

herrmarten commented Feb 1, 2017

Short: That error doesnt come from socket.io its a "No route to host" from chrome

I'm pretty sure you try to include the socket.io.js from your node-server, which isn't running.
Check your <script>-Tag (Like: <script src="http://your-host.tld:11111/socket.io/socket.io.js"></script>) Handle an error with an onerror-attribute defined for this script tag. You wont get this error out of your console, when you dont check if the server is running, before including the script tag.

@darrachequesne
Copy link
Member

Closed due to inactivity, please reopen if needed.

@kayzeeparacha
Copy link

kayzeeparacha commented Aug 1, 2017

What if we haven't included script tag for socket.io.js? Then how to solve this error?
I have angular 2 application , i just pointed out my chat component to hit the server initially and throwing error if server script is not running.

so.

this.socket.on('connect_error', function (data) {
        console.log('connection_error');
    });

By the above statement i was able to catch the connection error when server isn't started. Kindly specify the section in which you've written the code.

@icastillejogomez
Copy link

@kayzeeparacha This event catch the error however the error message is still displaying in console. I read in this post the message is not sending from socket.io and make sense. 😣

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

7 participants