TikTokLiveSharp icon indicating copy to clipboard operation
TikTokLiveSharp copied to clipboard

[BUG] Can't connect to websocket, The server returned status code '200' when status code '101' was expected

Open steampoweredtaco opened this issue 11 months ago • 4 comments

A recent TikTok changed broke websocket connections that do not include version_code=180800 in the query parameters for the websocket url. This is breaking everyone's C# clients.

The library seems like it might be reusing the headers that it also uses for the web client which breaks with version_code in it (that was another bug we fixed recently).

A gross hack that fixes this that I confirmed on my end:

diff --git a/TikTokLiveSharp/Client/TikTokBaseClient.cs b/TikTokLiveSharp/Client/TikTokBaseClient.cs
index 23bbbc3..d912869 100644
--- a/TikTokLiveSharp/Client/TikTokBaseClient.cs
+++ b/TikTokLiveSharp/Client/TikTokBaseClient.cs
@@ -550,6 +550,7 @@ namespace TikTokLiveSharp.Client
                 clientParams["cursor"] = response.Cursor;
                 clientParams["resp_content_type"] = "protobuf";
                 clientParams["internal_ext"] = response.InternalExt;
+                clientParams["version_code"] = "270000";
                 foreach (KeyValuePair<string, string> param in response.RouteParamsMap)
                 {
                     if (ShouldLog(LogLevel.Verbose))

I'm sure there is a better way to fix the code, but I'll leave it to ya'll @frankvHoof93

steampoweredtaco avatar Jan 28 '25 05:01 steampoweredtaco

A quick note, it looks like TT is updating their backend requirements quickly and now the version may need to be 270000 .

steampoweredtaco avatar Jan 28 '25 19:01 steampoweredtaco

Another note, it appears that the required value depends on knowledge only know to eulerstream... so we probably should hold off on patching this until we know the full story/fix.

steampoweredtaco avatar Jan 28 '25 19:01 steampoweredtaco

It is happening today... do you know wich is the current version?

somunich avatar Sep 11 '25 23:09 somunich

It is happening today... do you know wich is the current version?

Not sure @somunich . It might be a slightly different issue though. About the time you responded to this the go library broke with the same error. The fix there was to change the "User-Agent" query parameter so it did not have Mozilla/ prepended for the wss:// url and that resolved the issue.

beeblebrox avatar Sep 15 '25 02:09 beeblebrox