I have this kind of exception, on a production environnement:
Fatal error: Uncaught RuntimeException: Unable to create the cache
directory
(/app/ezplatform/var/cache/prod/a6d61d85393d8924b6a2d32272d325510651f125)
in
/app/ezplatform/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:765
Stack trace: #0
/app/ezplatform/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(642):
Symfony\Component\HttpKernel\Kernel->buildContainer() #1
/app/ezplatform/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(135):
Symfony\Component\HttpKernel\Kernel->initializeContainer() #2
/app/ezplatform/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php(195):
Symfony\Component\HttpKernel\Kernel->boot() #3
/app/ezplatform/web/app.php(64):
Symfony\Component\HttpKernel\Kernel->handle(Object(Symfony\Component\HttpFoundation\Request))
4 {main} thrown in /app/ezplatform/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php
on line 765
I don't understand why the response http code is 200 instead of 500, is it because a server low level exception ? How to customize the error page for this kind of situation.
This the response header:
HTTP/2.0 200 OK
content-type: text/html; charset=UTF-8
date: Wed, 18 Dec 2019 08:32:40 GMT
strict-transport-security: max-age=0
x-debug-info: eyJyZXRyaWVzIjowfQ==
x-request-id: z7m5kvoqa4smukjgb74pxhqd
x-robots-tag: noindex, nofollow
content-length: 982
X-Firefox-Spdy: h2
This error is caused by the Symfony cache generator, not by your application.
The application will try to generate it's cache on a folder, from the directory, but it can't access it. The folder var/cache/ must be allowed to be written by the user that is running the application, maybe your server user.
Changing this with a simple chmod USER_RUNNING_THE_APP +w var/cache -R will solve the issue most likely.
As for the issue about the the response header being 200 instead of 500, this is because the server can respond, and responses using the application. The application will return a response as 200 because will this:
route the response to the application
application does it's thing to generate an output
generates that error message
we have content, so this means it's 200, cause nothing else is specified
return 200 with the error message
Related
I have some URL and make a request to that URL but a response is invalid. I checked requests in Chrome dev tools and Chrome didn't find something wrong. I make a request in Postman but I receive "Parse Error: There seems to be an invalid character in response header key or value". Also I make requests in Axios in Node.js and I receive an error again.
After all, I checked request in chrome dev tools again and then I saw that:
Accept-Ranges: bytes
Connection: close
Date: Wed, 30 Jun 2021 12:05:28 GMT
Server: Boa/0.94.14rc21
There are parsed headers from the response and I clicked on a "View source" and saw that:
HTTP/1.1 200 OK
Date: Wed, 30 Jun 2021 12:05:28 GMT
Server: Boa/0.94.14rc21
Accept-Ranges: bytes
Connection: close
<Content-Type:text/html>
Is it normal or I should receive content-type without angle brackets? Maybe it's documented somewhere as a standart?
UPD. I made requests to a dashboard of Yeastar TG200
UPD 2. Also I made POST-requests and I received valid content-type in response headers without angle brackets
Angle brackets in a field name are definitively invalid (see https://greenbytes.de/tech/webdav/rfc7230.html#rule.token.separators).
I have a little Web API, almost directly from the standard VS project template, i.e. Home and Values controllers, and lots of MVC cruft. It is set to run and debug under IIS 10.
I have set up tracing by adding the package Microsoft.AspNet.WebApi.Tracing and the following code in WebApiConfig:
public static void Register(HttpConfiguration config)
{
config.EnableSystemDiagnosticsTracing();
SystemDiagnosticsTraceWriter traceWriter = config.EnableSystemDiagnosticsTracing();
traceWriter.IsVerbose = true;
traceWriter.MinimumLevel = TraceLevel.Debug;
config.Services.Replace(typeof(ITraceWriter), new SimpleTracer());
...
...
}
SimpleTracer is an ITraceWriter that writes to a text file.
When I call the API from outside the VS ecosystem, i.e. from PostMan in Chrome, a bad url, that results in a 404 error message, and the creation of a new trace file if there's not already one. Of I call it from PostMan with a good url, I get the expected result, and a trace of the request in the trace file.
When I call it from my Console app, even with a good url, I still get a 404 error response, and nothing is written to the trace file. I made sure by removing it and IIS doesn't even re-create it when using the .exe client.
If I call it from the compiled .exe from outside VS, I get the same error.
Then, when I set the Web API to use IIS Express, everything works perfectly. Do I need CORS for calls from non-web apps, does IIS need an extra header in this case? What is wrong?
EDIT A: This is the request when I use PostMan, and it returns a 200 and the expected list of strings.
GET /DemoApi/api/values HTTP/1.1
Host: localhost
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: f9454ffc-6a8d-e1ed-1a28-23ed8166e534
and the response and headers:
["value1","value2","value3","value4","value5","value6","value7"]
Cache-Control →no-cache
Content-Length →64
Content-Type →application/json; charset=utf-8
Date →Tue, 13 Dec 2016 06:20:07 GMT
Expires →-1
Pragma →no-cache
Server →Microsoft-IIS/10.0
X-AspNet-Version →4.0.30319
X-Powered-By →ASP.NET
EDIT B: This is the request sent using HttpClient:
GET http://abbeyofthelema/api/values HTTP/1.1
Accept: application/json
Host: abbeyofthelema
Connection: Keep-Alive
The only real difference is that because Fiddler doesn't capture traffic from localhost, I had to use my computer name instead. The same recipient still gets the request.
The response here is:
HTTP/1.1 404 Not Found
Cache-Control: private
Content-Type: text/html; charset=utf-8
Server: Microsoft-IIS/10.0
X-Powered-By: ASP.NET
Date: Tue, 13 Dec 2016 08:07:25 GMT
Content-Length: 4959
According to Timothy Shields at the following link
Why is HttpClient BaseAddress not working?
You must place a slash at the end of the BaseAddress, and you must not place a slash at the beginning of your relative URI
From the agile CRM doc, trying a few simple curl calls like this one (anonymised):
curl https://****.agilecrm.com/dev/api/contacts/*********** -H "Accept :application/xml" -v -u ********#***********:********************
And always same problem :
< HTTP/1.1 500 Internal Server Error
< Date: Mon, 29 Feb 2016 15:10:50 GMT
< Content-Type: text/html; charset=UTF-8
< Server: Google Frontend
< Content-Length: 323
< Alt-Svc: quic=":443"; ma=2592000; v="30,29,28,27,26,25"
<
Difficult to imagine any error in something that basic, but it doesn't work.
Any idea?
When registering from mobile, you often have 1st letter to be capitalized.
Then, in the agilecrm interface/backoffice, if you do not put the same cap at same place, you can't login. But if you put cap in your email in API call, the server crashes (Internal Server Error).
So beware, expected capitalisation isn't consistent across the different AgileCRM parts.
Authentication process at Agile CRM interface and Rest API level is same now. Now it is working with uppercase and lower case email with Rest API.
I try to update an object with WEB API hosted on a remote server. I recover well the object but at the time of the change, the answer gives 404 method not Allowed. I tested to host my service in a machine of my colleague just nearby. It works well. Is what is needed to make a configuration or something else?
Thank you a lot.
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage responsse = client.PutAsJsonAsync("api/Collaborateurs/" + coll.matricule_collaborateur, coll).Result;
if (responsse.IsSuccessStatusCode) {
}
Error:
{StatusCode: 405, ReasonPhrase: 'Method Not Allowed', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
{
Date: Thu, 12 Nov 2015 14:28:10 GMT
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Content-Length: 1343
Allow: GET
Allow: HEAD
Allow: OPTIONS
Allow: TRACE
Content-Type: text/html
}}
WebDAV is know to interfere with the verb PUT. Try uninstalling WebDAV if it is present on the server and you do not use it.
It may also be that you need to contact the remote server's administrator. PUT is sometimes blocked by network switches/routers. I.e. there well may be nothing you can do to fix this with code. Try using POST instead.
I am developing an HTTP proxy in Java. I resend all the data from client to server without touching it, but for some URLs (for example this) server returns the 404 error if I am connecting through my proxy.
The requested URL uses Varnish caching, so it might be the root of problem. I cannot reconfigure it - it is not my.
If I request that URL directly with browser, the server returns 200 and the image is shown correctly.
I am stuck because I even do not know what to read and how to compose a search request.
Thanks a lot.
Fix the Host: header of the re-issued request. The request going out from the proxy either has no Host header or it is broken (or only X-Host exists). Also take note that the proxy application will execute its own DNS lookup and that might yield a different IP address than your local computer (where you issued the original request).
This works:
> curl -s -D - -o /dev/null http://212.25.95.152/w/w-200/1902047-41.jpg -H "Host: msc.wcdn.co.il"
HTTP/1.1 200 OK
Content-Type: image/jpeg
Cache-Control: max-age = 315360000
magicmarker: 1
Content-Length: 27922
Accept-Ranges: bytes
Date: Sun, 05 Jul 2015 00:52:08 GMT
X-Varnish: 2508753650 2474246958
Age: 67952
Via: 1.1 varnish
Connection: keep-alive
X-Cache: HIT