Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8985769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:23:54+00:00 2026-06-15T21:23:54+00:00

I construct my websocket connection with this code (e.g.): var socket = new WebSocket(ws://94.12.176.177:8080);

  • 0

I construct my websocket connection with this code (e.g.):

var socket = new WebSocket("ws://94.12.176.177:8080");

And I close the connection with this one:

socket.close();

But how do I reestablish connection?

I’ve done some research and tried several methods. This question could not help me: Socket.io reconnect on disconnect?
It’s the only result which close to what I’m looking for.

The reason I want to do this is to allow users to stop sending data to the web temporary, and resending again after a period of time. Without reconnection, user have to refresh the page in order to resend. This may cause some data lost. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:23:55+00:00Added an answer on June 15, 2026 at 9:23 pm

    NOTE: The question is tagged socket.io so this answer is specifically regarding socket.io.
    As many people have pointed out, this answer doesn’t apply to vanilla websockets, which will not attempt to reconnect under any circumstances.

    Websockets will not automatically try to reconnect. You’ll have to recreate the socket in order to get a new connection. The only problem with that is you’ll have to reattach your handlers.

    But really, websockets are designed to stay open.

    A better method would be to have the server close the connection. This way the websocket will fire an onclose event but will continue attempting to make the connection. When the server is listening again the connection will be automatically reestablished.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given this plain JavaScript construct: var MyObject = function() { var privateArray = [
Trying to print on my webpage this: <?php // Usage: $master=new WebSocket(localhost,12345); class WebSocket{
For example we can construct such an array like this: new ElementType[0]; I seen
Which construct is better suited for this situation, an if-else or a switch? -
I am trying to construct a customized map in raphaeljs , in this i
I am trying to construct a deeply nested associative array but i don't know
This is specifically about GWT's RequestBuilder, but should apply to general XHR as well.
This is how I construct my stylized buttons. <span class='button button-orange' id='sign-up'><input type='button' value='Sign
I'm trying to construct a table with Prototype's New Element function. I was experiencing
What is this language construct called? In Python I can say: def a(b,c): return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.