bddvlpr / untis-ics-sync

Serves a calendar API (ICS) for events provided from Untis.
BSD 3-Clause "New" or "Revised" License
19 stars 2 forks source link

Requesting too many lessons causes server to ignore the request #31

Open doppelkorn opened 1 week ago

doppelkorn commented 1 week ago

Sup, just like the title suggests, the timetable fetching appears borked. No wonder since the WebUntis authors constantly change stuff around.

In order to reproduce:

  1. Grab latest build directly from the GitHub CI, environment variables all set to the according credents
  2. Boot container, try to access any lesson or timetable
  3. Error appears in console, server returns generic 500 error

Docker logs are as following:

untis-server-1  | [Nest] 1  - 09/22/2024, 9:10:10 PM   DEBUG [UntisService] No cache for TIMETABLE.1 exists.
untis-server-1  | [Nest] 1  - 09/22/2024, 9:10:11 PM   DEBUG [UntisService] Session is invalid. Renewing now...
untis-server-1  | [Nest] 1  - 09/22/2024, 9:10:11 PM     LOG [UntisService] Fetching timetable range 9/15/2024 to 10/6/2024...
untis-server-1  | [Nest] 1  - 09/22/2024, 9:10:11 PM    WARN [ExpressAdapter] Content-Type doesn't match Reply body, you might need a custom ExceptionFilter for non-JSON responses
untis-server-1  | [Nest] 1  - 09/22/2024, 9:10:11 PM   ERROR [ExceptionsHandler] Server didn't return any result.
untis-server-1  | Error: Server didn't return any result.
untis-server-1  |     at Queue.onFailed (/app/node_modules/bull/lib/job.js:516:18)
untis-server-1  |     at Queue.emit (node:events:518:28)
untis-server-1  |     at module.exports.emitSafe (/app/node_modules/bull/lib/utils.js:50:20)
untis-server-1  |     at EventEmitter.messageHandler (/app/node_modules/bull/lib/queue.js:476:15)
untis-server-1  |     at EventEmitter.emit (node:events:518:28)
untis-server-1  |     at DataHandler.handleSubscriberReply (/app/node_modules/ioredis/built/DataHandler.js:80:32)
untis-server-1  |     at DataHandler.returnReply (/app/node_modules/ioredis/built/DataHandler.js:47:18)
untis-server-1  |     at JavascriptRedisParser.returnReply (/app/node_modules/ioredis/built/DataHandler.js:21:22)
untis-server-1  |     at JavascriptRedisParser.execute (/app/node_modules/redis-parser/lib/parser.js:544:14)
untis-server-1  |     at Socket.<anonymous> (/app/node_modules/ioredis/built/DataHandler.js:25:20)

OS: openSUSE Leap 15.5 Docker Version: Docker version 24.0.7-ce Untis-ics-version: 0.7.2

If you need any further info I will provide it to you asap

bddvlpr commented 1 week ago

As of recently Untis started combatting applications like mine by setting a secret limit as to the amount of classes you can fetch and will just randomly return with an empty body if you try to request over an unlisted amount of lessons. I had a 'workaround' on this that would fetch the lessons in separate requests but still all at once that I might bring back soon.

For the time being I suggest you put down the LESSONS_TIMETABLE_BEFORE and LESSONS_TIMETABLE_AFTER to a smaller number until it stops erroring. As I currently don't have access to a WebUntis instance I cannot work on it for a while, I'm in the process of trying to get access to a server in the meantime.