Getting com.google.gwt.user.client.rpc.StatusCodeException: 0 in GWT

前端 未结 4 593
清酒与你
清酒与你 2021-02-14 21:29

I sometimes/often get this Exception in GWT but don\'t know why:

SEVERE: com.google.gwt.user.client.rpc.StatusCodeException: 0 
java.lang.RuntimeException: com.g         


        
相关标签:
4条回答
  • 2021-02-14 21:37

    Although the original poster probably had issues with their network connection I got the same error today inside GWT hosted mode. And not sometimes, but all the time.

    I have now figured it out, and I'd like to share it here so other people searching for a sollution to the 0 status code problem can find it.

    If you use the Rpc security tokens that GWT provides (as in this explanation: http://www.gwtproject.org/doc/latest/DevGuideSecurityRpcXsrf.html) against cross site scripting but you forget to set the security token for whatever reason then one of the things you might run into is the zero result.

    I've designed my webapplication so that most RPC calls are mostly made within a framework. Today I needed to create an RPC service by hand. Forgot to set the RPCToken, got empty response from the server.

    Hope this helps somebody out.

    0 讨论(0)
  • 2021-02-14 21:51

    Since there is no HTTP status code 0, this appears not to be from the server - it could be worthwhile to test using Firebug or something, just to make sure that there isn't a bad response like this coming back.

    Instead, this is almost certainly from the browser itself, either the connection timed out or was dropped by the server, or the browser couldn't reach the server (bad dns, bad gateway, lost wifi, server not available).

    Treat this like any unexpected server failure - perhaps back off and try again, display a message to the user, log an error and send that when the connections are working again.

    The fact that it is happening in all browsers points to a network or server issue - it is extremely unlikely that all browsers are failing in unpredictable ways together. This fact also makes it easier to debug - you can use your favorite browser's debug tools.

    0 讨论(0)
  • 2021-02-14 21:55

    I have found that if you hang an rpc call on the server (Thread.wait()) and the browser is refreshed then on the client side just before it loads the page again it will call the onFailure method of the waiting callback with the above mentioned status code which suggests it orginates in the client or that it is a generic error code for non-specific caught exceptions.

    0 讨论(0)
  • 2021-02-14 22:00

    This happens to us if our authentication layer determines that a session has expired and redirects an RPC request to the login page on a different host. Since AJAX requests cant go to a different host, the browser aborts the request and signals status code 0. See https://code.google.com/p/google-web-toolkit/issues/detail?id=2858

    Its crazy too because GWT will throw a StatusCodeException with code 0 even though the HTTP code that appears in Firebug / Chrome Inspector is clearly a 302.

    0 讨论(0)
提交回复
热议问题