Error 400 when using Session ID to use the same IP for a second request
w
webmastah
started a topic
about 5 years ago
Hi everyone.
Let's see if someone can help me out or, at least, point me in the right direction. I need to use X-Crawlera-Session headers so that I can send a second request to the same slave (IP).
For this, I use X-Crawlera-Session: create in the first request. And get the session ID correctly in the response. I parse the response and use this session id number as a header (X-Crawlera-Session: sessionId) in the second request.
However, the result is always an error 400 (invalid session id). I can't seem to find the error. Been struggling with it all day and looking for information in the forum and docs, but you can hardly find something for PHP.
Thanks everyone in advance!
Best Answer
n
nestor
said
about 5 years ago
The problem is that the session ID that you're passing in the second request is incorrect.
You can use the list sessions endpoint to double check that the ID that you're storing the in the variable is correct https://doc.scrapinghub.com/crawlera.html#list-sessions. You also don't need to view the logs to see the session ID in the response, just print out the response headers.
Any chance of anyone who has faced the same issue? I would appreciate any help or hint... Thanks in avance!
t
trackrn6
said
about 5 years ago
I am having this same issue.
nestor
said
about 5 years ago
Most likely you're not storing/capturing the value of the session ID from response header properly.
I would suggest you print/output the response header and the value of your variable for the sessionID and see if they match.
Another reason for 400 error code is the session limit, but it comes with the message user_session_limit. C10 plans have only up to 100 active sessions.
w
webmastah
said
about 5 years ago
Actually, Nestor, I am requestion the creation of the session (X-Crawlera-Session: create) and receive the sessionID correctly. I am outputting both the variable, as parsed by me, along with the response I receive and they do match.
However, when I pass the header 'X-Crawlera-Session: 33176487090’ (note this id is just a sample ID) in the second request as a header (so that I can use the same IP for both requests), then I get this error denying the sessionID and, therefore, I cannot compare it with the one I already received in the first request.
I have tried checking in the admin and in the logs (created and downloaded in the CSV option), but they do not appear or do not include the sessionID.
Any idea what the problem can be? Thanks a lot in advance.
nestor
said
about 5 years ago
Answer
The problem is that the session ID that you're passing in the second request is incorrect.
You can use the list sessions endpoint to double check that the ID that you're storing the in the variable is correct https://doc.scrapinghub.com/crawlera.html#list-sessions. You also don't need to view the logs to see the session ID in the response, just print out the response headers.
w
webmastah
said
about 5 years ago
Great! Now it's working. I got to see the session ID's by using terminal instead of looking at the logs. It was a problem with the quotes.
webmastah
Hi everyone.
Let's see if someone can help me out or, at least, point me in the right direction. I need to use X-Crawlera-Session headers so that I can send a second request to the same slave (IP).
For this, I use X-Crawlera-Session: create in the first request. And get the session ID correctly in the response. I parse the response and use this session id number as a header (X-Crawlera-Session: sessionId) in the second request.
However, the result is always an error 400 (invalid session id). I can't seem to find the error. Been struggling with it all day and looking for information in the forum and docs, but you can hardly find something for PHP.
Thanks everyone in advance!
The problem is that the session ID that you're passing in the second request is incorrect.
You can use the list sessions endpoint to double check that the ID that you're storing the in the variable is correct https://doc.scrapinghub.com/crawlera.html#list-sessions. You also don't need to view the logs to see the session ID in the response, just print out the response headers.
2 people have this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest Firstwebmastah
Any chance of anyone who has faced the same issue? I would appreciate any help or hint... Thanks in avance!
trackrn6
I am having this same issue.
nestor
Most likely you're not storing/capturing the value of the session ID from response header properly.
I would suggest you print/output the response header and the value of your variable for the sessionID and see if they match.
Another reason for 400 error code is the session limit, but it comes with the message user_session_limit. C10 plans have only up to 100 active sessions.
webmastah
Any idea what the problem can be? Thanks a lot in advance.
nestor
The problem is that the session ID that you're passing in the second request is incorrect.
You can use the list sessions endpoint to double check that the ID that you're storing the in the variable is correct https://doc.scrapinghub.com/crawlera.html#list-sessions. You also don't need to view the logs to see the session ID in the response, just print out the response headers.
webmastah
Great! Now it's working. I got to see the session ID's by using terminal instead of looking at the logs. It was a problem with the quotes.
Thanks a lot and again! ;)
nestor
No problem.
-
Crawlera 503 Ban
-
Amazon scraping speed
-
Website redirects
-
Error Code 429 Too Many Requests
-
Bing
-
Subscribed to Crawlera but saying Not Subscribed
-
Selenium with c#
-
Using Crawlera with browsermob
-
CRAWLERA_PRESERVE_DELAY leads to error
-
How to connect Selenium PhantomJS to Crawlera?
See all 388 topics