Closed codesunshine closed 3 years ago
Hi @codesunshine, thanks for opening this issue.
I'll be glad to help you, but to do that I think I will need a bit more details. If you could put a bit more effort in describing your issue than just pasting a stacktrace. it would be really appreciated. For example: when do you get this? Can you provide a code snippet that you are running that throws this exception? Have you done any investigation yourself?
Also, PRs are welcome :)
Thanks
Thank you very much!
I got an error while executing the login method。
This is code:
URL serverUrl = new URL("https", "api.opensubtitles.org", 443, "/xml-rpc");
XmlRpcClientConfigImpl config = new XmlRpcClientConfigImpl();
config.setServerURL(serverUrl);
config.setConnectionTimeout(30000);
config.setReplyTimeout(1000);
config.setGzipCompressing(true);
OpenSubtitlesClient osClient = new OpenSubtitlesClientImpl(config);
// logging in
Response response = osClient.login(
"my name", "my password", "zh",
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36");
I registered on https://www.opensubtitles.org/zh
Hi @codesunshine thanks for providing the code sample. There are two problems - one with the library, and one with your code.
Firstly, the library should not fail at parsing the response, clearly a bug that needs fixing.
However, the root cause of this is that opensubtitles api responds with:
12:15:04.385 [main] DEBUG c.g.w.o.x.c.RetryableXmlRpcClient - Response: {seconds=0.001, status=parse error. not well formed}
This is because your XmlRpcClientConfigImpl
is improper, you set config.setGzipCompressing(true);
which does not work without config.setEnabledForExtensions(true);
.
Sample config that should work:
XmlRpcClientConfigImpl xmlRpcClientConfig = new XmlRpcClientConfigImpl();
xmlRpcClientConfig.setServerURL(serverUrl);
xmlRpcClientConfig.setEnabledForExtensions(true);
xmlRpcClientConfig.setGzipCompressing(true);
xmlRpcClientConfig.setGzipRequesting(true);
Another problem is with your user agent. According to opensubtitles documentation, you should be using TemporaryUserAgent
for your tests unless you have applied with opensubtitles for your custom user agent.