Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid 400 on initial check-in -attempt #325

Open
studgeek opened this issue Dec 30, 2024 · 4 comments
Open

Avoid 400 on initial check-in -attempt #325

studgeek opened this issue Dec 30, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@studgeek
Copy link

Description

Per @jdholtz, a 400 at check-in usually means the attempt was too early (as it went through in later attempts). This can happen on the first attempt as the time isn’t exactly synchronized between the Southwest servers and NTP servers.

One experiment could be checking in a second or two after the minute to see if we can avoid this first attempt failure. This may then speed up the check-in as it takes ~4 seconds for the first attempt to report a failure before the script tries again.

What alternatives have you considered?

No response

@studgeek studgeek added the enhancement New feature or request label Dec 30, 2024
@studgeek
Copy link
Author

Here is example of 400 on first attempt by the script...

$ pipenv run python3 southwest.py XXXXXX My Name -v
2024-12-21 11:28:31 DEBUG MainProcess[log:24]: Initialized the application
2024-12-21 11:28:31 DEBUG MainProcess[main:113]: Auto-Southwest Check-In v8.1
2024-12-21 11:28:31 DEBUG MainProcess[main:71]: Called with 3 arguments
2024-12-21 11:28:31 DEBUG MainProcess[config:143]: Initializing configuration file
2024-12-21 11:28:31 DEBUG MainProcess[config:172]: Reading the configuration file
2024-12-21 11:28:31 DEBUG MainProcess[config:176]: No configuration file found. Using defaults
2024-12-21 11:28:31 DEBUG MainProcess[config:185]: Reading configuration from environment variables
2024-12-21 11:28:31 DEBUG MainProcess[main:84]: Adding reservation through CLI arguments
...
2024-12-21 17:25:05 DEBUG Process-1:1[checkin_handler:119]: Sleeping until check-in: 1794 seconds...
Checking in to flight from 'Oakland' to 'Phoenix' for My Name

2024-12-21 17:55:00 DEBUG Process-1:1[checkin_handler:169]: Attempting to check in
2024-12-21 17:55:00 DEBUG Process-1:1[checkin_handler:204]: Making first POST request to check in
2024-12-21 17:55:04 DEBUG Process-1:1[utils:90]: Request error on attempt 1: Bad Request (400). Sleeping for 0.50 seconds until next attempt
2024-12-21 17:55:06 DEBUG Process-1:1[utils:70]: Successfully made request after 2 attempts
2024-12-21 17:55:06 DEBUG Process-1:1[checkin_handler:211]: Making second POST request to check in
2024-12-21 17:55:08 DEBUG Process-1:1[utils:70]: Successfully made request after 1 attempts
2024-12-21 17:55:08 DEBUG Process-1:1[checkin_handler:179]: Successfully checked in after 1 attempts
2024-12-21 17:55:08 DEBUG Process-1:1[notification_handler:119]: Sending successful check-in notification...

Version info:

M$ git l2 -1
* 2fde441 - Sun, 24 Nov 2024 20:00:00 -0600 (4 weeks ago) (HEAD, origin/develop)
|           Update changelog to include JSON schema addition - jdholtz

@studgeek
Copy link
Author

I tried adding just a second as follows...

--- a/lib/checkin_handler.py
+++ b/lib/checkin_handler.py
@@ -78,7 +78,7 @@ class CheckInHandler:

     def _set_check_in(self) -> None:
         # Check-in is 24 hours before the flight departs
-        checkin_time = self.flight.departure_time - timedelta(days=1)
+        checkin_time = self.flight.departure_time - timedelta(days=1) + timedelta(seconds=1)

I still had a 400 though. And resulting seats were not great...

2024-12-29 16:20:05 DEBUG Process-1:1[checkin_handler:119]: Sleeping until check-in: 1795 seconds...
Checking in to flight from 'Phoenix' to 'Oakland' for David Rees

2024-12-29 16:50:01 DEBUG Process-1:1[checkin_handler:169]: Attempting to check in
2024-12-29 16:50:01 DEBUG Process-1:1[checkin_handler:208]: Making first POST request to check in
2024-12-29 16:50:05 DEBUG Process-1:1[utils:91]: Request error on attempt 1: Bad Request (400). Sleeping for 0.20 seconds until next attempt
2024-12-29 16:50:11 DEBUG Process-1:1[utils:70]: Successfully made request after 2 attempts
2024-12-29 16:50:11 DEBUG Process-1:1[checkin_handler:215]: Making second POST request to check in
2024-12-29 16:50:14 DEBUG Process-1:1[utils:70]: Successfully made request after 1 attempts
2024-12-29 16:50:14 DEBUG Process-1:1[checkin_handler:183]: Successfully checked in after 1 attempts
2024-12-29 16:50:14 DEBUG Process-1:1[notification_handler:119]: Sending successful check-in notification...

@studgeek
Copy link
Author

Could try adding another second.

Or, I wonder if we could have the script run multiple tabs (like I sometimes do manually in the browser). For example, it could start checkin in tab 1 at exact checkin time, tab 2 at +1 seconds, and tab 3 at +2 seconds.

@jdholtz
Copy link
Owner

jdholtz commented Dec 31, 2024

For example, it could start checkin in tab 1 at exact checkin time, tab 2 at +1 seconds, and tab 3 at +2 seconds.

That's a good idea. I can come up with a proof of concept for this so we can evaluate how well it does in practice. Do you have a check-in coming up soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants