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

[atmosphere.js] Cannot set client request timeout and get WebSocket error #860

Closed
sophiaso opened this issue Jan 28, 2013 · 5 comments
Closed
Labels

Comments

@sophiaso
Copy link

Similar with issue: #291
I'm using client version 1.0.9.
I configured the timeout for the request (for some debug) as the following:
var request = {
timeout: 60000,
url : URL,
contentType : "application/json",
shared : true,
transport : "websocket",
fallbackTransport: "long-polling",
};
But seems the client does not automatically timeout after 60 seconds, it only aborted after 300 seconds as default. Speaking about the abort, it's some warning message:
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). jquery.atmosphere.js:2435
Websocket closed, wasClean: false jquery.atmosphere.js:2435
Request reconnected

I have searched the above error, you have mentioned in other tickets that it may caused by proxy or firewall, but the error always repeats after 5 mins, which is the default timeout. Is there any relationship between this error and the timeout? Mine output msg is different with #291. It shows close reason for idle time, but here is something abnormal, any idea? Reply is appreciated.

Thanks,
Zoe

@jfarcand
Copy link
Member

Hi,

  • which browser
  • is the onOpen callback being invoked?
  • Can you share a test case

Thanks!

@sophiaso
Copy link
Author

I'm using chrome, version: 24.0.1312.56 m. OS: win7.
onOpen callback is invoked, if the connection was "closed abnormally" after 5 minutes, the onReconnect is invoked.

I'm giving a simplified version test case ( already tried on my own PC).
Server Side:


@Path("/MyResourcePath")
public class MyResource {
    @Suspend
    @Path("/connect")
    @GET
    public String connect() {
        return "";
    }
}

Client:


var socket = $.atmosphere;
var subSocket;
function connect(onSuccess, onError) {
  var URL = getResourceUrl();
  
  var request = { 
      timeout: 60000,
      url : URL,
      contentType : "application/json",
      shared : true,
      transport : "websocket",
      fallbackTransport: "long-polling",
  };
  
  request.onOpen = function(response) {
      console.log("Request opened ");
  };
  request.onReconnect = function (request, response) {
      console.log("Request reconnected");
  };
  
  request.onMessage = function(response) {
    onSuccess(response);
  };
  
  request.onClose= function(response) {
    console.log("Request onClose");
  };
  
  request.onError = function(response) {
    console.log("Request onError");
  };
  
  subSocket = socket.subscribe(request);
}

The console log:

Request opened  
Websocket closed, reason: Connection was closed abnormally (that is, with no close frame being sent). jquery.atmosphere.js:2435
Websocket closed, wasClean: false jquery.atmosphere.js:2435
Request onClose 
Request reconnected 

@sophiaso
Copy link
Author

What will happen if the client request some forbidden resources? Eg, when the server rejected with a 403 code, I would like to do some operations but not reconnect again, but each time I check the status of the response, it's 200.

jfarcand added a commit that referenced this issue Feb 1, 2013
@jfarcand
Copy link
Member

jfarcand commented Feb 1, 2013

@ZoePan If the websocket fail to connect (503 or anything else), the onOpen will not be called. Where do you get 403?

@jfarcand jfarcand closed this as completed Feb 1, 2013
jfarcand added a commit that referenced this issue Feb 1, 2013
@sophiaso
Copy link
Author

sophiaso commented Feb 4, 2013

Thanks for your reply and looking into on this. I will figure out the status code next time if I meet that again.

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

No branches or pull requests

2 participants