question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

server.close() does not work??

See original GitHub issue
describe.only('Websockets store handlers', () => {
  let store;

  beforeEach(() => {
    store = createStore(ws,
      applyMiddleware(
        thunk,
        promise,
      )
    );
  });

  it('connects the websocket', () => {
    const server = new Server('ws://qorus.example.com/log/main');

    store.subscribe(() => {
      const { data } = store.getState();

      expect(data).to.eql({
        'log/main': {
          loading: true,
          connected: false,
          error: false,
          paused: false,
        },
      });
    });

    store.dispatch(actions.connect('log/main'));

    server.close();
  });

  it('disconnects the websocket', () => {
    const server = new Server('ws://qorus.example.com/log/main');

    store.dispatch(actions.connect('log/main'));
    store.subscribe(() => {
      const { data } = store.getState();

      expect(data).to.eql({
        'log/main': {
          loading: false,
          connected: false,
          error: false,
          paused: false,
        },
      });
    });
    store.dispatch(actions.disconnect('log/main'));

    server.close();
  });
});
  1. Websockets store handlers disconnects the websocket: Error: A mock server is already listening on this url

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
tuzmusiccommented, Dec 3, 2019

I’m having a similar “already listening” problem, and I tried

new Server('socketioserverurl', {
     forceNew: true,
     reconnection: false
})

and first typescript said those weren’t valid keys, and when I @ts-ignore that error, I still have the same ‘already listening’ problem.

3reactions
Foxhoundncommented, Sep 5, 2016

Sorry, It’s actually server.stop(), but that doesn’t really matter since that one does not work either 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I shutdown a Node.js http(s) server immediately?
close() will close the process, as long as there's nothing else keeping the process alive. If you need to do other things after...
Read more >
HTTP server.close() does not shut down, process hangs #41895
close() is called, or check in setupListenHandle() to make sure the server is not shut down before opening the socket.
Read more >
Node.js server.close() Method - W3Schools
Definition and Usage. The server.close() method stops the HTTP server from accepting new connections. All existing connections are kept.
Read more >
Node.js http.server.close() Method - GeeksforGeeks
The http.server.close() is an inbuilt application programming interface of class Server within the HTTP module which is used to stop the server ...
Read more >
How to terminate a HTTP server in Node.js?
server.stop() stops the server from accepting new connections and keeps existing connections. This function is asynchronous, the server is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found