tgvmax-bot
tgvmax-bot copied to clipboard
Log error and backend down using Trainline Checker
Hi there,
I've been experiencing an error since 2 days ago that forces my backend container to restart every minute. Would you know what is it about? Here is the recurring (30+ times) errir I get on my logs before every restart:
` 2 travel(s) initiated. 0 cron(s) initiated. App listen on 0.0.0.0:8080
/usr/src/src/book/trainline.ts:298 this.token.passengers = token.passengers.filter(p => p.is_selected) ^ TypeError: Cannot read properties of undefined (reading 'filter') at TrainlineAuthentifier.login (/usr/src/src/book/trainline.ts:298:46) at processTicksAndRejections (node:internal/process/task_queues:96:5) at TrainlineAuthentifier.getToken (/usr/src/src/book/trainline.ts:262:7) at TrainlineSearcherAndBooker.search (/usr/src/src/book/trainline.ts:654:22) at Object.next (/usr/src/src/book/trainline.ts:552:21) at TrainlineSearcherAndBooker.list (/usr/src/src/book/trainline.ts:490:41) at TrainlineSearcherAndBooker.check (/usr/src/src/book/trainline.ts:735:19) `
Thank you for your tool and time !
Try to connect to your Trainline business account to ensure your credentials are still valid
Trainline acocunt still running and website research with it shows me TGVmax places
UPDATE: Getting a captcha check from the signin endpoint Token in JSON format looks like this: {"url":"https://geo.captcha-delivery.com/captcha/?initialCid=XXX&cid=XXX&referer=HTTPS%3A%2F%2Fwww.trainline.fr%2Fapi%2Fv5_1%2Faccount%2Fsignin&hash=XXX&t=fe&s=XXXXX&e=XXXXX"}
The current code use those hardcoded creds: https://github.com/Eywek/tgvmax-bot/blob/master/backend/src/book/trainline.ts#L22, they might just have changed them
Same issue here !
Also, we should improve the behaviour when something like that happens, because the backend is now restarting a lot, and the frontend doesn't display any information (it looks like you lost all your data)
Same issue here too. Is there a fix available or not yet ?
A PR has been opened (https://github.com/Eywek/tgvmax-bot/pull/29) but wasn't finished so feel free to make another one
A PR has been opened (#29) but wasn't finished so feel free to make another one
That PR isn't about the issue we're facing here. Either the API changed, or the credentials. Someone needs to investigate, see what Trainline web or mobile app is using/sending, and make a PR 😅
So I tried to dig a little into that problem, and I think the problem is that they have an anti-bot system.
Like @Grodzeus said :
UPDATE: Getting a captcha check from the signin endpoint
When I use the website I'm often asked to complete the captcha to proceed. However, the but can't complete it thus returning a null request. I don't know if any of you have a workaround but, if not, does this means the bot is dead?
I don't know if any of you have a workaround but, if not, does this means the bot is dead?
You should try to replicate how HTTP requests are done by the Trainline business application
I already compared the requests between the bot and the app and I don't think the requests are the problem here.
However, we still have the same issue :
Even in the Business app, we're asked to complete the captcha.
Thanks for the investigation @MrVidipy !
btw, I tried months ago to send them a mail to get a legal access to the api, after seeing https://www.thetrainline.com/solutions/api and they never answered...
However, we could maybe send this captcha to the frontend then, with a little bit of code modifications 🤔
btw, I tried months ago to send them a mail to get a legal access to the api, after seeing https://www.thetrainline.com/solutions/api and they never answered...
I just send a mail to ask about their pricing. We'll see if they respond.
However, we could maybe send this captcha to the frontend then, with a little bit of code modifications 🤔
Yeah, why not but it defies the goal of the bot if the captcha is required during the night. And from what I saw, Trainline is asking for the captcha very often (like every few requests).
I just send a mail to ask about their pricing. We'll see if they respond.
I hope you'll have better luck than me
Yeah, why not but it defies the goal of the bot if the captcha is required during the night. And from what I saw, Trainline is asking for the captcha very often (like every few requests).
You're right, sadly it won't work well... And I'm not sure we're eager to go down the path of captcha solvers
the initial issue is fixed by https://github.com/Eywek/tgvmax-bot/commit/0e7dcd2accff9e583b90bdd6ac8197c09cd9f33a
But Trainline is still trying to block us with a captcha, personally I don't use "travels" anymore and I only use the bot UI to search for available TGVMax