-
Notifications
You must be signed in to change notification settings - Fork 23
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
TwitchAPI disconnects every 30 minutes #38
Comments
Same issue, but I still need to update gift to the latest build,but it does seem to disconnect (since December) . If I got any valuable debug information I will add it here. |
This issue should be renamed: I dug a little more into HTTPClient class to figure out what was wrong. I believe the problem was related to having a request call while My hacky and NOT IDEAL solution has been to wait to finish polling the body within the Original code in func poll() -> void:
client.poll()
if (client.get_status() == HTTPClient.STATUS_BODY):
client_response += client.read_response_body_chunk()
elif (!client_response.is_empty()):
received_response.emit(client_response.get_string_from_utf8())
client_response.clear()
func request(method : int, url : String, headers : PackedStringArray, body : String = "") -> Dictionary:
client.request(method, url, headers, body)
var response = await(received_response)
match (client.get_response_code()):
401:
id_conn.token_invalid.emit()
return {}
return JSON.parse_string(response) My edits to code in func poll() -> void:
client.poll()
if (client.get_status() == HTTPClient.STATUS_BODY):
client_response += client.read_response_body_chunk()
elif (!client_response.is_empty()):
received_response.emit(client_response.get_string_from_utf8())
client_response.clear()
func request(method : int, url : String, headers : PackedStringArray, body : String = "") -> Dictionary:
# --- MY HACKED SOLUTION
while client.get_status() != HTTPClient.STATUS_CONNECTED:
while client.get_status() == HTTPClient.STATUS_CONNECTING:
await get_tree().create_timer(0.1).timeout
if client.get_status() in [HTTPClient.STATUS_DISCONNECTED, HTTPClient.STATUS_CONNECTION_ERROR]:
client.connect_to_host("https://api.twitch.tv", -1, TLSOptions.client())
else:
client.poll()
if client.get_status() == HTTPClient.STATUS_BODY:
client_response += client.read_response_body_chunk()
elif (!client_response.is_empty()):
received_response.emit(client_response.get_string_from_utf8())
# --- MY HACKED SOLUTION
client.request(method, url, headers, body)
var response = await(received_response)
match (client.get_response_code()):
401:
id_conn.token_invalid.emit()
return {}
return JSON.parse_string(response) I am not confident in my network connection knowledge, so I won't suggest this as a definitive solution. But I hope this can help somehow. EDIT: In the original response I used |
Nice work @iRadEntertainment ! I get this as my output currently in debug mode (as spam) : So it probably is indeed to do with re-establishing of the connection. Also I have been tinkering with other APIs and the reconnection problem is also found in a few other APIs, if I read their message boards. So perhaps something has changed since last year that breaks some connection codes. This week I should be able to test a few setups as well, if I can add any fresh findings to this discussion I will. My speciality is not really in networking so lets see how it goes. |
Can't seem to use the updated EDIT: I still get eventual disconnects and status -1 |
So apparently the client connection cannot stay open forever and it disconnects after some time.
The text was updated successfully, but these errors were encountered: