I am using GuzzleHttp to send post request to another project. But when I have error I can't see all error it is always truncated.
Can anyone know how to remove the (truncated...) so that I can fully see the error?
GuzzleHttp\Exception\ServerException
Server error: POST http://127.0.0.1:8000/api/api resulted in a 500 Internal Server Error response: <!doctype html> <!-- TypeError: Argument 1 passed to Illuminate\Database\Query\Builder::inser (truncated...)
The error is only truncated in the Guzzle Exception message. You find the error in full in the other projects' PHP error log if you enable error logging there -- and -- in the response body.
Right now you've enabled display errors (or you're displaying errors in some variant that inserts the message into a HTML comment), check error logging is enabled and locate the appropriate log file.
Alternatively you can configure Guzzle to not throw on "HTTP errors"[1], verify the response status is 500 and if so have the non-truncated information in the response body.
The truncation is only for convenience as exception messages often end up in some line of their own in the PHP error log (of the applications that don't catch it) and such lines have a common limit of 1024 bytes for portability reasons.
Most details of the error situation can only be available within the system (here: the HTTP server you send requests to) and if you want to obtain the least filtered information, always go towards the source. Don't look for things, just obtain them.
c.f. Catching exceptions from Guzzle for the version of the Guzzle API you have in use.
Related
I'm using a extension of my PHP website for SSO which uses guzzle. It gives this error when running it.
Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 35: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) in.....
When I went to the website mentioned in the error for error 35 it says:
CURLE_SSL_CONNECT_ERROR (35)
A problem occurred somewhere in the SSL/TLS handshake. You really want the error buffer and read
the message there as it pinpoints the problem slightly more. Could be certificates (file formats, paths,
permissions), passwords, and others.
Top of the website tells this.
No matter what, using the curl_easy_setopt option CURLOPT_ERRORBUFFER is a good idea as it will
give you a human readable error string that may offer more details about the cause of the error
than just the error code.
As mentioned in the website how do I use CURLOPT_ERRORBUFFER in guzzle.
Any answers are appreciated.
Please let me know what I should do.
Is there a general explanation for the errors that lead to the phenomenon described in the title? Can I make the program tell me the actual cause of these errors?
Assuming you are using PHP backend, HTTP status 500 would mean internal server error - a bug that caused your PHP script to halt. Usually fatal errors cause this.
When you get a 500 error, click on the request in firebug. It would open up all kinds of request data like Headers, Response, Cache, Params etc. Check the response tab once. That might give you a clue about what's wrong in your PHP code.
An HTTP status code of 500 means the error happened on the server side. Firebug only sees what's happening on the client side - i.e. it tells you that the server returned an error code. It doesn't have access to the errors happening on the server side.
I.e. you need to check the log files of your server to see what caused the error. This is normally a fatal error in your server-side script that caused its execution to stop.
I am using an OAuth library to connect to my Etsy store (etsy.com) and try to retrieve some information regarding sold orders.
This is the library: https://github.com/Lusitanian/PHPoAuthLib/blob/master/examples/etsy.php
However, I keep getting an error after I "Allow Access". I receive a token but when I allow access the issue is happening.
Here is the full error:
Fatal error: Uncaught exception 'OAuth\Common\Http\Exception\TokenResponseException' with message 'file_get_contents(http://openapi.etsy.com/v2/private/users/__SELF__): failed to open stream: HTTP request failed!
HTTP/1.1 400 Bad Request ' in /hermes/bosoraweb013/b1151/ipg.tahara/APIs/PHPoAuthLib-master/src/OAuth/Common/Http/Client/StreamClient.php:70 Stack trace: #0 /hermes/bosoraweb013/b1151/ipg.tahara/APIs/PHPoAuthLib-master/src/OAuth/OAuth1/Service/AbstractService.php(137):
OAuth\Common\Http\Client\StreamClient->retrieveResponse(Object(OAuth\Common\Http\Uri\Uri), NULL, Array, 'GET') #1 /hermes/bosoraweb013/b1151/ipg.tahara/APIs/PHPoAuthLib-master/examples/etsy.php(47):
OAuth\OAuth1\Service\AbstractService->request('/private/users/...') #2 {main} thrown in /hermes/bosoraweb013/b1151/ipg.tahara/APIs/PHPoAuthLib-master/src/OAuth/Common/Http/Client/StreamClient.php on line 70
Would anyone have any input to identify what the issue is?
The error is telling you that the library was getting back a 400 error which means that the server does not like your request. If this is something that might happen more often than not then a try catch block is your friend if only to terminate gracefully and perhaps log the problem.
If this was me I would have the error, the request and the Library object print_r inside a tag or into a text document so I could get a better idea of what was going on.
I'd be wondering if this was an authentication issue, a need to use HTTPS rather than HTTP, a bug in the library, an end-point issue or just some bad data at some place or other. The more information you have and the more you can isolate and confirm as working the faster I could home in on the problem.
I wish you the best of luck debugging and tracing the fault. I know how insanely frustrating these things can be.
some times my site server is in too many connection status and mysql show error: (could not connect: too many connection), but question is how we must set a google friendly or in general a bot friendly HTTP header error for such a this situation in PHP? my means is set a error to tell them my site is temporary down! come back latter!
Send a 500 Internal Server Error:
header('HTTP/1.0 500 Internal Server Error');
I hope you have wrapped you code by some exception handler or error handler and you have a global exception handler for your application.What you can do here is, in the error handler, you can throw an exception which will have some message you want to display. This can be caught by the global application exception handler which will redirect the user to some custom page which you want to show.
Iam parsing a page and im getting response from that but after some time i.e. after some of the parsing gets done i get this error from the server -
Proxy Error
The proxy server received an invalid response from an upstream server.
The proxy server could not handle the request GET /file.php.
Reason: Error reading from remote server
and after this my parsing fails.
I even tried sleep() function but it didnt helped and the error still came.
Are they temporarily blocking my ip or what??
What could be the reason for this and how can i parse those pages without getting this error and all ???
Why don't you use CURL to fetch the page contents and then parse them? let me know if this works or you need any help.
--Pinaki