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.

HttpResponseListener.handleHttpResponse is called if no internet connection on gwt

See original GitHub issue

Issue details

If client no internet connection, method Gdx.net.sendHttpRequest(request, listener) not call failed or cancelled. Exception not thrown. Only for GWT. On desktop and android failed method called.

Reproduction steps/code

Send request multiple time (every 5 sec). Turn off internet, responce listener not called failed or cancelled. Exception print in console.

Version of LibGDX and/or relevant dependencies

1.9.10

Stacktrace

net::ERR_INTERNET_DISCONNECTED

of infinity time with timeout.

Please select the affected platforms

  • Android
  • iOS
  • HTML/GWT
  • Windows
  • Linux
  • MacOS

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
MobiDevelopcommented, Feb 3, 2021

It’s very odd behavior for GWT to call onResponseReceived when no response was, in fact, received. I wouldn’t think that other platforms treat this scenario the same way as they’d likely hit an IOException and call failed.

1reaction
MrStahlfelgecommented, Feb 1, 2021

According to the GWT documentation, onResponseReceived may get called for failed requests with status code 0:

public abstract int getStatusCode()

Returns the HTTP status code that is part of this response.

The value will be 0 if the request failed (e.g. network error, or the server disallowed the request) or has been aborted (this will generally be the case when leaving the page).

We could handle this and call failed() from here with an own exception:

https://github.com/libgdx/libgdx/blob/bc314368a18e0c916437f3dd7b4172714e6abf8b/backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/GwtNet.java#L163

It would be “more correct”, but a behaviour change. I am not familiar if other platforms might not call handleHttpResponse with status code 0 though - @MobiDevelop @Tom-Ski what’s your opinion on this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How should I handle "No internet connection" with Retrofit on ...
If no network, throw an exception as appropriate. This allows one to specifically handle network connectivity issues before hitting Retrofit. import java.io.
Read more >
No Internet Connection? How to Troubleshoot Internet Issues
Is your Wi-Fi connected but you still aren't getting internet? We've put together a guide to help you troubleshoot your network and get...
Read more >
Fix internet connection problems on Android devices
If you can't access the Internet on your Android device, either through an app or a website, try these troubleshooting steps. Signs of...
Read more >
If your iPhone or iPad won't connect to a Wi-Fi network
Go to Settings > Wi-Fi and make sure that Wi-Fi is on. Tap the name of your Wi-Fi network to join. A blue...
Read more >
Troubleshooting Wi-Fi connection on your Surface
Your Surface shows that it's connected to your wireless network but it's not working or “limited” may appear under your Wi-Fi network name...
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