kalkih / passport-appointment-bot

Bot to automatically find and book appointment for renewal/creation of a Swedish passport or national identity card.
24 stars 9 forks source link

socket hang up #27

Closed danwie closed 2 years ago

danwie commented 2 years ago

Not sure if they changed anything. Suddenly I get "socket hang up". But if I enter the booking site manually it seems to work fine (although a litte slow). I've also tried different ip-addresses (VPN) but with the same result.

$ ./passport-appointment-bot-macos-x64 
[13:13:52] [info]   Validating configuration...
[13:13:52] [success]    Configuration is valid
[13:13:52] [info]   Validating configured region...
[13:13:52] [success]    Valid region Stockholm
[13:13:52] [info]   Validating configured locations...
[13:13:52] [success]    Valid locations Järva, Sollentuna, Solna, Sthlm City, Södra Roslagen
[13:13:52] [info]   Starting booking session...
[13:13:52] [verbose]    Started captcha webserver on port 51827

/snapshot/pass-bot/node_modules/node-fetch/lib/index.js:1491
            reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
                   ^
FetchError: request to https://bokapass.nemoq.se/Booking/Booking/Index/stockholm failed, reason: socket hang up
    at ClientRequest.<anonymous> (/snapshot/pass-bot/node_modules/node-fetch/lib/index.js:1491:11)
    at ClientRequest.emit (node:events:390:28)
    at TLSSocket.socketOnEnd (node:_http_client:471:9)
    at TLSSocket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}
dio99 commented 2 years ago

Not sure if they changed anything. Suddenly I get "socket hang up". But if I enter the booking site manually it seems to work fine (although a litte slow). I've also tried different ip-addresses (VPN) but with the same result.

$ ./passport-appointment-bot-macos-x64 
[13:13:52] [info] Validating configuration...
[13:13:52] [success]  Configuration is valid
[13:13:52] [info] Validating configured region...
[13:13:52] [success]  Valid region Stockholm
[13:13:52] [info] Validating configured locations...
[13:13:52] [success]  Valid locations Järva, Sollentuna, Solna, Sthlm City, Södra Roslagen
[13:13:52] [info] Starting booking session...
[13:13:52] [verbose]  Started captcha webserver on port 51827

/snapshot/pass-bot/node_modules/node-fetch/lib/index.js:1491
          reject(new FetchError(`request to ${request.url} failed, reason: ${err.message}`, 'system', err));
                 ^
FetchError: request to https://bokapass.nemoq.se/Booking/Booking/Index/stockholm failed, reason: socket hang up
    at ClientRequest.<anonymous> (/snapshot/pass-bot/node_modules/node-fetch/lib/index.js:1491:11)
    at ClientRequest.emit (node:events:390:28)
    at TLSSocket.socketOnEnd (node:_http_client:471:9)
    at TLSSocket.emit (node:events:402:35)
    at endReadableNT (node:internal/streams/readable:1343:12)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  type: 'system',
  errno: 'ECONNRESET',
  code: 'ECONNRESET'
}

same issue for me now with that

17:56.785Z"} {"level":"error","message":"Reached maximum redirect of 20 for URL: https://bokapass.nemoq.se/Booking/403.htm","timestamp":"2022-04-04T11:17:56.828Z"} {"level":"error","message":"Reached maximum redirect of 20 for URL: https://bokapass.nemoq.se/Booking/403.htm","timestamp":"2022-04-04T11:17:56.900Z"} {"level":"error","message":"Reached maximum redirect of 20 for URL: https://bokapass.nemoq.se/Booking/403.htm","timestamp":"2022-04-04T11:17:57.897Z"} {"level":"error","message":"Reached maximum redirect of 20 for URL: https://bokapass.nemoq.se/Booking/403.htm","timestamp":"2022-04-04T11:18:29.049Z"}

MartinHage commented 2 years ago

I am also having the same issue. The bot worked fine until around 2022-04-04 12:30 CET but after a restart I started getting this error.

xxandeer commented 2 years ago

I did try it now and I also getting socket hang up at ClientRequest.

skajagpangadig commented 2 years ago

Tried it aswell and same error. Hopefully it will be patched soon so people wont need to queue at arlanda at 3am XD

liato commented 2 years ago

Works for me when if I patch the fetch function and change the user agent:

Change: https://github.com/kalkih/passport-appointment-bot/blob/9e61b6e5e16262af94b8a7e19a121de4455e928a/src/services/bookingService.js#L35

To:

    this._fetch = fetchCookie(nodeFetch)
    this.fetch = async function(url, options) {
      options = options || {}
      let headers = {
          "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4844.52 Safari/537.36"
      }
      Object.assign(headers, options.headers || {})
      options.headers = headers
      return this._fetch(url, options)
    };
xxandeer commented 2 years ago

@liato I can confirm that your change does work. Thanks

dio99 commented 2 years ago

Works for me when if I patch the fetch function and change the user agent:

Change:

https://github.com/kalkih/passport-appointment-bot/blob/9e61b6e5e16262af94b8a7e19a121de4455e928a/src/services/bookingService.js#L35

To:

    this._fetch = fetchCookie(nodeFetch)
    this.fetch = async function(url, options) {
      options = options || {}
      let headers = {
          "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4844.52 Safari/537.36"
      }
      Object.assign(headers, options.headers || {})
      options.headers = headers
      return this._fetch(url, options)
    };

nice but i have some dep when try to build from src :(

rc $ cd .. ~/passport-appointment-bot $ npm install npm WARN passport-appointment-bot@3.3.0 No repository field. npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules/fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})