Closed derhuerst closed 3 years ago
When I'm asking for departures in the next minute I get a valid answer. Code snipped:
const thalwil = '8503202' // Thalwil client.departures(thalwil, {duration: 1}) ...
But when I'm asking for departures in the next 10 minutes I get an error. Code snipped:
const thalwil = '8503202' // Thalwil client.departures(thalwil, {duration: 10}) ...
Currently, I cannot confirm that. I use the debug-cli
helper, but it basically does the same:
./tools/debug-cli/cli.js sbb departures 8503202 | jq
# works, I get departures
./tools/debug-cli/cli.js sbb departures 8503202 '{duration: 10}' | jq
# works too
Possible causes:
hafas-client
to more/different options with the request.You can help me debug this by running your tests with the DEBUG=hafas-client
environment variable. This way, I can see all raw requests and responses.
Managed to reproduce with KPublicTransport, not for Thalwil (8503202) though, but Basel SBB (8500010).
Request: {"auth":{"aid":"hf7mcf9bv3nv8g5f","type":"AID"},"client":{"id":"DBZUGRADARNETZ","type":"AND"},"formatted":false,"lang":"de","svcReqL":[{"meth":"ServerInfo","req":{"getServerDateTime":true,"getTimeTablePeriod":false}},{"cfg":{"polyEnc":"GPA"},"meth":"StationBoard","req":{"date":"20210413","maxJny":20,"stbFltrEquiv":true,"stbLoc":{"extId":"8500010","type":"S"},"time":"165204","type":"DEP"}}],"ver":"1.18"}
Response: {"ver":"1.18","lang":"deu","id":"dq26xkxmga449i8x","err":"OK","svcResL":[{"meth":"ServerInfo","err":"OK","res":{"common":{"locL":[],"prodL":[],"polyL":[],"layerL":[{"id":"standard","name":"standard","index":0,"annoCnt":0}],"crdSysL":[{"id":"standard","index":0,"type":"WGS84"}],"opL":[],"remL":[],"icoL":[]},"sD":"20210413","sT":"165204","enc":"ISO-8859-1","planrtTS":"1618325456"}},{"meth":"StationBoard","err":"CGI_READ_FAILED"}]}
Further observations:
{"auth":{"aid":"hf7mcf9bv3nv8g5f","type":"AID"},"client":{"id":"DBZUGRADARNETZ","type":"AND"},"formatted":false,"lang":"de","svcReqL":[{"meth":"ServerInfo","req":{"getServerDateTime":true,"getTimeTablePeriod":false}},{"cfg":{"polyEnc":"GPA"},"meth":"StationBoard","req":{"date":"20210413","maxJny":20,"stbFltrEquiv":true,"stbLoc":{"crd":{"x":7590210,"y":47546980},"type":"C"},"time":"165959","type":"DEP"}}],"ver":"1.18"}
) with the same error.Okay, with 10 minutes it works now for me also. But with 20 minutes not.
You can help me debug this by running your tests with the DEBUG=hafas-client environment variable. This way, I can see all raw requests and responses.
I have no experience with enviroment variables in node. I found something with duckduckgo and tried this, but I don't get a helpful result. How do I do that?
You can help me debug this by running your tests with the
DEBUG=hafas-client
environment variable. [...]I have no experience with environment variables in node. [...]
Environment variables are a shell/OS thing, rather than a Node-specific thing.
On Unix-like operating systems (macOS, Linux) and if you're using bash
(the default shell on almost all Unix-like OSes), you would just add DEBUG=hafas-client
in front of your command, e.g. DEBUG=hafas-client node my-hafas-client-test-script.js
.
On Windows, I think it depends on the shell (PowerShell vs cmd.exe
vs something else) you're using.
Oh, okay. Thank you :slightly_smiling_face: Here is my request command (under Debian) and the result:
$ DEBUG=hafas-client node ./tools/debug-cli/cli.js sbb departures 8503202 '{duration: 20}' | jq
{"lang":"deu","svcReqL":[{"meth":"StationBoard","req":{"type":"DEP","date":"20210414","time":"181703","stbLoc":{"type":"S","lid":"A=1@L=8503202@"},"dirLoc":null,"jnyFltrL":[{"type":"PROD","mode":"INC","value":"1023"}],"dur":20,"getPasslist":false,"stbFltrEquiv":false}}],"client":{"type":"AND","id":"DBZUGRADARNETZ","v":""},"ver":"1.18","auth":{"aid":"hf7mcf9bv3nv8g5f","type":"AID"}}
{"ver":"1.18","lang":"deu","id":"","err":"OK","svcResL":[{"meth":"StationBoard","err":"CGI_READ_FAILED"}]}
Error: CGI_READ_FAILED
at Object.request (/.../hafas-client/lib/request.js:108:14)
at _stationBoard (/.../sbb-problem/hafas-client/index.js:76:18)
at departures (/.../sbb-problem/hafas-client/index.js:87:10)
at Object.<anonymous> (/.../sbb-problem/hafas-client/tools/debug-cli/cli.js:61:1)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47 {
isHafasError: true,
request: '{"lang":"deu","svcReqL":[{"meth":"StationBoard","req":{"type":"DEP","date":"20210414","time":"181703","stbLoc":{"type":"S","lid":"A=1@L=8503202@"},"dirLoc":null,"jnyFltrL":[{"type":"PROD","mode":"INC","value":"1023"}],"dur":20,"getPasslist":false,"stbFltrEquiv":false}}],"client":{"type":"AND","id":"DBZUGRADARNETZ","v":""},"ver":"1.18","auth":{"aid":"hf7mcf9bv3nv8g5f","type":"AID"}}',
url: 'http://fahrplan.sbb.ch/bin/mgate.exe?',
statusCode: 200,
code: 'CGI_READ_FAILED',
responseId: null
}
Is that helpful?
Is that helpful?
Yes and no. 😄 It didn't help me figure out in which specific case the SBB endpoint returns CGI_READ_FAILED
, but as requested it documents another request that causes it. 👍
Closing since the SBB seems to be shut off (#245).
from https://github.com/public-transport/hafas-client/issues/228#issuecomment-817372799: