frankvHoof93 / TikTokLiveSharp

Port of TikTok live library for C#
https://vanhoof.dev
Other
140 stars 28 forks source link

WebException timeout #24

Closed Blurbss closed 10 months ago

Blurbss commented 11 months ago

Setup the example project in unity and am trying to connect to multiple streams and getting timed out every time. Any ideas?

image

frankvHoof93 commented 11 months ago

Http-Requests are only sent during initial connect (to scrape the TikTokLive-Page for the required data (such as RoomId)). If these are timing out, it sounds like you're unable to access the actual TikTokLiveStream-Page for the user?

vashe96 commented 10 months ago

I receive same issue on all users and projects:

WebException: The operation has timed out. System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func1[TResult] aborted, System.Threading.CancellationTokenSource cts) (at :0) System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) (at :0) System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) (at :0) --- End of stack trace from previous location where exception was thrown --- System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) (at :0) Rethrow as HttpRequestException: An error occurred while sending the request System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) (at :0) System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) (at :0) TikTokLiveSharp.Client.HTTP.TikTokHttpRequest.GetContent () (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:180) TikTokLiveSharp.Client.HTTP.TikTokHttpRequest.Get () (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:140) TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetSignedUrl (System.String url, System.Collections.Generic.Dictionary2[TKey,TValue] parameters) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:172) TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetRequest (System.String url, System.Collections.Generic.Dictionary2[TKey,TValue] parameters, System.Boolean signURL) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:126) TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetDeserializedMessage (System.String path, System.Collections.Generic.Dictionary2[TKey,TValue] parameters, System.Boolean signURL) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:64) TikTokLiveSharp.Client.TikTokBaseClient.FetchClientData () (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:600) TikTokLiveSharp.Client.TikTokBaseClient.Connect (System.Action1[T] onConnectException) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:418) TikTokLiveSharp.Client.TikTokLiveClient.Connect (System.Action1[T] onConnectException) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokLiveClient.cs:266) TikTokLiveSharp.Client.TikTokBaseClient.Start (System.Nullable1[T] cancellationToken, System.Action1[T] onConnectException, System.Boolean retryConnection) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:317) UnityEngine.Debug:LogException(Exception, Object) TikTokLiveSharp.Client.<Start>d__42:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:367) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.d132:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokLiveClient.cs:270) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception) TikTokLiveSharp.Client.d43:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:425) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.<FetchClientData>d__49:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:603) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d4:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:65) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d9:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:127) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.<GetSignedUrl>d__12:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:185) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d19:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:140) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d22:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:197) UnityEngine.UnitySynchronizationContext:ExecuteTasks()

frankvHoof93 commented 10 months ago

TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetSignedUrl (System.String url

Signing server is down currently. It's maintained by the owner of the Python-lib, so there's nothing I can do about that.

vashe96 commented 10 months ago

Can you provide this lib repository to push the owner?

frankvHoof93 commented 10 months ago

https://github.com/isaackogan/TikTokLive Not currently online on Discord, so I'm not expecting an immediate response.

vashe96 commented 10 months ago

Same issue occurs

Blurbss commented 10 months ago

The way I solved this was going directly into the library code and brute-force increasing the timeout limit. It took on average like a minute or two to connect for me, so it was giving up way too early. Hope that helps.

vashe96 commented 10 months ago

The way I solved this was going directly into the library code and brute-force increasing the timeout limit. It took on average like a minute or two to connect for me, so it was giving up way too early. Hope that helps.

Could you provide the solution please?

Blurbss commented 10 months ago

The way I solved this was going directly into the library code and brute-force increasing the timeout limit. It took on average like a minute or two to connect for me, so it was giving up way too early. Hope that helps.

Could you provide the solution please?

In Constants.cs image

vashe96 commented 10 months ago

Doesn't work, then I receive new error:

HttpRequestException: Request was unsuccessful [502] TikTokLiveSharp.Client.HTTP.TikTokHttpRequest.GetContent () (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:186) TikTokLiveSharp.Client.HTTP.TikTokHttpRequest.Get () (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:140) TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetSignedUrl (System.String url, System.Collections.Generic.Dictionary2[TKey,TValue] parameters) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:172) TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetRequest (System.String url, System.Collections.Generic.Dictionary2[TKey,TValue] parameters, System.Boolean signURL) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:126) TikTokLiveSharp.Client.HTTP.TikTokHTTPClient.GetDeserializedMessage (System.String path, System.Collections.Generic.Dictionary2[TKey,TValue] parameters, System.Boolean signURL) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:64) TikTokLiveSharp.Client.TikTokBaseClient.FetchClientData () (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:600) TikTokLiveSharp.Client.TikTokBaseClient.Connect (System.Action1[T] onConnectException) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:418) TikTokLiveSharp.Client.TikTokLiveClient.Connect (System.Action1[T] onConnectException) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokLiveClient.cs:266) TikTokLiveSharp.Client.TikTokBaseClient.Start (System.Nullable1[T] cancellationToken, System.Action1[T] onConnectException, System.Boolean retryConnection) (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:317) UnityEngine.Debug:LogException(Exception, Object) TikTokLiveSharp.Client.<Start>d__42:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:367) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.d132:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokLiveClient.cs:270) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception) TikTokLiveSharp.Client.d43:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:425) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.<FetchClientData>d__49:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/TikTokBaseClient.cs:603) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d4:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:65) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d9:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:127) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.<GetSignedUrl>d__12:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHTTPClient.cs:185) System.Runtime.CompilerServices.AsyncTaskMethodBuilder1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d19:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:140) System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1:SetException(Exception) TikTokLiveSharp.Client.HTTP.d22:MoveNext() (at Library/PackageCache/dev.vanhoof.tiktokliveunity@235e10ef40/TikTokLiveSharp/Client/HTTP/TikTokHttpRequest.cs:197) UnityEngine.UnitySynchronizationContext:ExecuteTasks()

vashe96 commented 10 months ago

Should I try some kind of retry mechanism?