Page 1 of 2

Bug uploading to dedimania

Posted: 04 Jul 2019, 16:32
by elie520
Hello,

When I restart a map (using //res), sometimes, the connection to Dedimania fails. It happens about 30% of the time, and mostly when I've played the map for more than, say, 15 minutes. I usually only get a "Dedimania error", but this time I got this
Image

As you can imagine, it's pretty frustrating when you want to upload a score (you end up praying to the PyPlanet gods for the score to go through, and it's not always the case :( ). Any idea why this happens and how to correct it?
It kind of looks like if PyP was opening a connection with Dedimania at the beginning of the map, and that Dedimania closed it after a few minutes (which is normal bcs they have no buisiness keeping open connections for nothing). I don't know.

If you have any question, I'll try to answer.

Thanks for your help!

Re: Bug uploading to dedimania

Posted: 04 Jul 2019, 16:51
by Miss
Not a PyPlanet dev or expert, but I do know that Dedimania is a terribly slow and unstable service in itself. When I was developing my own controller I've had countless issues like this, as well as dedimania just never responding to any request at all for long periods of time.

I think you should be praying to the Dedimania gods instead of the PyPlanet gods :P

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 08:48
by elie520
Thanks for your answer!
Miss wrote:
04 Jul 2019, 16:51
I think you should be praying to the Dedimania gods instead of the PyPlanet gods :P
I don't know, it's the first time I see this on a PyPlanet server, so I think I probably did something wrong in setting it up, that's why I'm asking for help :)

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 09:59
by Miss
You probably set it up correctly if it times out only 30% of the time. It's just dedimania being dedimania, unfortunately. PyPlanet is already re-trying requests up to 5 times, so as you can see, it's not a great service.

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 10:23
by toffe
I can confirm what Miss is telling. Some servers have servere trouble with connecting to Dedimania, while others don't have this at all. It seems like the location or route to the dedimania server might be badly from some other data center locations. The service itself is also slow and unreliable in general.

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 10:24
by elie520
Hmmm, I can see this

Code: Select all

self.headers = {
			'User-Agent': 'PyPlanet/{}'.format(version),
			'Accept': 'text/xml',
			'Accept-Encoding': 'gzip',
			'Content-Type': 'text/xml; charset=UTF-8',
			'Content-Encoding': 'gzip',
			'Keep-Alive': 'timeout=600, max=2000',
			'Connection': 'Keep-Alive',
}
I'm not sure, but doesn't it mean that PyP is opening a connection with Dedimania at the start of the map, and trying to keep it open for the whole duration of the map? If the map is played for more than 2000 seconds, isn't the connection shut down, leading to an error?
If so, I'm not sure keeping an inactive connection for a long time is the way to go (in general in web programming I mean).

Again, thx for your answers.

Edit: Just saw your answer Toffe. Okok, this sucks :( But it's still weird as I never had that problem with uaseco when it was still alive.

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 10:51
by toffe
I completely agree with you that keeping a long connection open is not generally a good thing to do as HTTP is stateless and should work any time. However the developers of Dedimania are forcing you to keep the connection open to lower the load on their side. (source: http://dedimania.net:8082/Dedimania)

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 11:13
by elie520
Indeed. I don't quite understand how this is suppose to be better for their servers. Especially if there a thousands of open connections. Anyway, I tried once more waiting for about 30 minutes, and after //res, same error. I think Dedimania is trying to close the connection as soon as it can (after the timeout if idle). Don't you think sending an empty request every, say, 300 seconds, would solve the problem?? I'm curious about that.

Edit: Tried again with 11 minutes on the map, same error.

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 11:28
by toffe
Well, the traffic to dedimania is huge, and therefor, keeping a connection open might be better than opening on every request. Keep in mind that the service is free of charge and relies on donations (which they don't get so much).

The Keep-Alive mechanism keeps the connection alive by sending small packages every x time if I'm correct. We might need to increase the keep-alive time. PyPlanet should reconnect if the connection is failed tho, and it seems that either this doesn't work or even reconnecting has no result.

Re: Bug uploading to dedimania

Posted: 05 Jul 2019, 11:40
by elie520
I'm not sure the client needs to send anything to keep the connection alive after the server agrees to keep it alive. Sending frequent request could artificially keep the connection non idle, but as you mentionned, one could also increase the timeout. This is a bad idea imo, because if the client suddenly disappears without properly closing the connection, Dedimania wouldn't be notified, and thus would keep an idle connection alive for a long time, for nothing.
I'm not sure how TCP works anymore, but after the timeout, if Dedimania closes the connection on its own without telling PyP first, PyP might never know? Thus, PyPlanet doesn't see any "failed connection", and so won't reconnect.

In the end, I think the better idea would be to set timeout to a few minutes (10 minutes is fine as it's already done), and making sure the connection isn't idle every 5 minutes.