I have a .net service that runs in a container.
When I run it I have a very wired issue.
Assuming I have the link HTTP//:www.a.com/page.
The first attempt to call HTTP//:www.a.com/page succeeds, the second failed with 500, the third succeeded again, and so on.
In the output window, I can find: Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll and Exception thrown: 'System.Net.Http.HttpRequestException'.
Initially, I thought that all the odd requests succeeded, but then more random patterns started to appear.
I tried to wait a few random seconds between attempts but it did not solve the issue.
Basically, some of the requests succeeded and some did not (again they are all exactly the same requests).
I added UseDeveloperExceptionPage. but it didn't catch anything, I added a BP on my first middleware, the requests that succeed break in it, the 500 never reach that point.
This led me to think that something is rung with Kerstel himself.
I returning 404 on the path, maybe Kerstel has caching mechanized that return automatically 500 if I repeat asking for a 404 path under x minutes?
The question is, how can I debug it? Where is the source of this bug?
This is the current setup of the Program.cs file:
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddHealthChecks();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseSwagger();
app.UseSwaggerUI();
}
// Should be the first middleware
app.UseHealthChecks("/HealthCheck");
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.Map("/{**catch-all}", async httpContext =>
{
// return 200 if we are healthy here
httpContext.Response.StatusCode = 404;
return;
});
});
Console.WriteLine("Test Version 6");
app.Run();
public partial class Program { } // so you can reference it from tests
-- edit --
When I use localhost (swagger) to communicate with .net, there is no error, only when I use it through the docker naming (using a regular browser request) there is an error, here are the traces:
Trace of swagger request (return 404 as expected):
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.1 GET http://localhost:50182/category_1a1a1a1a%2Fproduct_2a2a2a2a%2Fid_1123467.product?sig=EEF7952F7B823B6981A797AAE429DF - -
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[2]
All hosts are allowed.
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[3]
The request path does not match the path filter
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001]
1 candidate(s) found for the request path '/category_1a1a1a1a%2Fproduct_2a2a2a2a%2Fid_1123467.product?sig=EEF7952F7B823B6981A797AAE429DF'
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
Endpoint '/{**catch-all}' with route pattern '/{**catch-all}' is valid for the request path '/category_1a1a1a1a%2Fproduct_2a2a2a2a%2Fid_1123467.product?sig=EEF7952F7B823B6981A797AAE429DF'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1]
Request matched endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/{**catch-all}'
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[9]
Connection id "0HMJER5USLLOE" completed keep alive response.
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.1 GET http://localhost:50182/category_1a1a1a1a%2Fproduct_2a2a2a2a%2Fid_1123467.product?sig=EEF7952F7B823B6981A797AAE429DF - - - 404 0 - 3126.3906ms
The thread 0xf12 has exited with code 0 (0x0).
The thread 0xf0f has exited with code 0 (0x0).
The thread '.NET ThreadPool Worker' (0xb2) has exited with code 0 (0x0).
The thread '.NET ThreadPool Worker' (0xbf) has exited with code 0 (0x0).
The thread '.NET ThreadPool Worker' (0xc1) has exited with code 0 (0x0).
The thread '.NET ThreadPool Worker' (0xb8) has exited with code 0 (0x0).
The thread 0xf14 has exited with code 0 (0x0).
The thread 0xf15 has exited with code 0 (0x0).
The thread 0xf10 has exited with code 0 (0x0).
Trace of browser request (return 404 as expected but with wired failures):
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[39]
Connection id "0HMJER5USLLOF" accepted.
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[1]
Connection id "0HMJER5USLLOF" started.
info: Microsoft.AspNetCore.Hosting.Diagnostics[1]
Request starting HTTP/1.0 GET http://proxy_backend/category_1a1a1a1a/product_2a2a2a2a/id_1123467.product?sig=EEF7952F7B823B6981A797AAE429DF - -
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[2]
All hosts are allowed.
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[3]
The request path does not match the path filter
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001]
1 candidate(s) found for the request path '/category_1a1a1a1a/product_2a2a2a2a/id_1123467.product'
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
Endpoint '/{**catch-all}' with route pattern '/{**catch-all}' is valid for the request path '/category_1a1a1a1a/product_2a2a2a2a/id_1123467.product'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1]
Request matched endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
Executing endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
Executed endpoint '/{**catch-all}'
info: Microsoft.AspNetCore.Hosting.Diagnostics[2]
Request finished HTTP/1.0 GET http://proxy_backend/category_1a1a1a1a/product_2a2a2a2a/id_1123467.product?sig=EEF7952F7B823B6981A797AAE429DF - - - 404 0 - 1959.3089ms
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[10]
Connection id "0HMJER5USLLOF" disconnecting.
dbug: Microsoft.AspNetCore.Server.Kestrel.Connections[2]
Connection id "0HMJER5USLLOF" stopped.
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[7]
Connection id "0HMJER5USLLOF" sending FIN because: "The Socket transport's send loop completed gracefully."
dbug: Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets[6]
Connection id "0HMJER5USLLOF" received FIN.
Then the trace of the next browser request (return 500 - failure):
Exception thrown: 'System.UriFormatException' in System.Private.Uri.dll
Exception thrown: 'System.UriFormatException' in System.Private.CoreLib.dll
Exception thrown: 'System.UriFormatException' in System.Private.CoreLib.dll
It looks like everything is normal when I access .net using http://localhost:50182/ but when I access it from http://proxy_backend (the docker name) only then I get the issues
Related
I have a very simple flask app that is deployed on GKE and exposed via google external load balancer. And getting random 502 responses from the backend-service (added a custom headers on backend-service and nginx to make sure the source and I can see the backend-service's header but not nginx's)
The setup is;
LB -> backend-service -> neg -> pod (nginx -> uwsgi) where pod is the application built using flask and deployed via uwsgi and nginx.
The scenario is to handle image uploads in simple-secured way. Sender sends me a token with upload request.
My flask app
receive request and check the sent token via another service using "requests".
If token valid, proceed to handle the image and return 200
If token is not valid, stop and send back a 401 response.
First, I got suspicious about the 200 and 401's. And reverted all responses to 200. Following some of the expected responses, server starts to respond 502 and keep sending it. "Some of the messages at the very beginning succeeded".
nginx error logs contains below lines
2023/02/08 18:22:29 [error] 10#10: *145 readv() failed (104: Connection reset by peer) while reading upstream, client: 35.191.17.139, server: _, request: "POST /api/v1/imageUpload/image HTTP/1.1", upstream: "uwsgi://127.0.0.1:21270", host: "example-host.com"
my uwsgi.ini file is as below;
[uwsgi]
socket = 127.0.0.1:21270
master
processes = 8
threads = 1
buffer-size = 32768
stats = 127.0.0.1:21290
log-maxsize = 104857600
logdate
log-reopen
log-x-forwarded-for
uid = image_processor
gid = image_processor
need-app
chdir = /server/
wsgi-file = image_processor_application.py
callable = app
py-auto-reload = 1
pidfile = /tmp/uwsgi-imgproc-py.pid
my nginx.conf is as below
location ~ ^/api/ {
client_max_body_size 15M;
include uwsgi_params;
uwsgi_pass 127.0.0.1:21270;
}
Lastly, my app has a healthcheck method with simple JSON response. It does no extra stuff and simply returns. This never fails as explained above.
Edit : my nginx access logs in the pod shows the response as 401 while the client receives 502.
for those who gonna face with the same issue, the problem was post data reading (or not reading).
nginx was expecting to get post data read by the proxied, in our case uwsgi, app. But according to my logic I was not reading it in some cases and returning back the response.
Setting uwsgi post-buffering solved the issue.
post-buffering = %(16 * 1024 * 1024)
Which led me to this solution;
https://stackoverflow.com/a/26765936/631965
Nginx uwsgi (104: Connection reset by peer) while reading response header from upstream
I am still using Corda 1.0 version. when i try to redeploy nodes with existing data, getting below error while start-up but able to access the nodes . If i clear the data and redeploy the nodes, i didn't face these error message.
Logs can be found in :
C:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\kotlin-
source\build\nodes\xxxxxxxx\logs
Database connection url is : jdbc:h2:tcp://xxxxxxxxx/node
E 18:38:46+0530 [main] core.client.createConnection - AMQ214016: Failed to
create netty connection
javax.net.ssl.SSLException: handshake timed out
at io.netty.handler.ssl.SslHandler.handshake(...)(Unknown Source) ~[netty
all-4.1.9.Final.jar:4.1.9.Final]
Incoming connection address : xxxxxxxxxxxx
Listening on port : 10014
RPC service listening on port : 10015
Loaded CorDapps : corda-finance-1.0.0, kotlin-
source-0.1, corda-core-1.0.0
Node for "xxxxxxxxxxx" started up and registered in 213.08 sec
Welcome to the Corda interactive shell.
Useful commands include 'help' to see what is available, and 'bye' to shut
down the node.
Wed May 23 18:39:20 IST 2018>>> E 18:39:24+0530 [Thread-6 (ActiveMQ-server-
org.apache.activemq.artemis.core.server.impl.ActiveMQServerImp
l$3#4a532271)] core.client.createConnection - AMQ214016: Failed to create
netty connection
javax.net.ssl.SSLException: handshake timed out
at io.netty.handler.ssl.SslHandler.handshake(...)(Unknown Source) ~[netty-
all-4.1.9.Final.jar:4.1.9.Final]
This looks like the Artemis failed to connect to the node which means the node fails to start.
You should look at the log and if there are any other previous Corda node started which occupy the node.
If there are any legacy Corda nodes that have not been killed, try ps -ef |grep java to see if there is any other java still alive. Especially look for the port number and check if they are overlapped
I have a requirement to invoke a backend service endpoint which accepts requests of type application/json. It is a pass through API with no logic implemented before invocation.
I have a request payload in JSON with 2000 lines for POST method.
Once, I invoke the API, it doesn't call the backend service but tries to convert payload from JSON to XML and then failed.
Is it the expected behavior of API Manager where it converts all incoming requests in JSON to XML during processing before invoking back-end service.
Also, after failure API is moving into suspended state.
Any suggestions would be helpful.
Error below.
TID: [-1234] [] [2018-02-13 07:25:30,999] WARN {org.apache.synapse.endpoints.EndpointContext} - Suspending endpoint : AnonymousEndpoint with address http://localhost:{uri.var.portnum}/savepolicy/1.0 - current suspend duration is : 30000ms - Next retry after : Tue Feb 13 07:26:00 EET 2018 {org.apache.synapse.endpoints.EndpointContext}
TID: [-1234] [] [2018-02-13 07:25:30,999] INFO {org.apache.synapse.mediators.builtin.LogMediator} - STATUS = Executing default 'fault' sequence, ERROR_CODE = 101507, ERROR_MESSAGE = Error in Sender {org.apache.synapse.mediators.builtin.LogMediator}
TID: [-1234] [] [2018-02-13 07:25:31,000] ERROR {org.apache.synapse.commons.json.JsonUtil} - #toXml. Could not convert JSON Stream to XML. Cannot handle JSON input. Error>>> null {org.apache.synapse.commons.json.JsonUtil}
TID: [-1234] [] [2018-02-13 07:25:31,000] ERROR {org.apache.synapse.transport.passthru.util.DeferredMessageBuilder} - Error building message {org.apache.synapse.transport.passthru.util.DeferredMessageBuilder}
org.apache.axis2.AxisFault: Could not convert JSON Stream to XML. Cannot handle JSON input.
at org.apache.synapse.commons.json.JsonUtil.toXml(JsonUtil.java:298)
at org.apache.synapse.commons.json.JsonBuilder.processDocument(JsonBuilder.java:35)
at org.apache.synapse.transport.passthru.util.DeferredMessageBuilder.getDocument(DeferredMessageBuilder.java:148)
at org.apache.synapse.transport.passthru.util.RelayUtils.builldMessage(RelayUtils.java:136)
at org.apache.synapse.transport.passthru.util.RelayUtils.buildMessage(RelayUtils.java:99)
at org.apache.synapse.mediators.AbstractListMediator.buildMessage(AbstractListMediator.java:140)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:83)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:214)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:59)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:158)
at org.apache.synapse.mediators.MediatorFaultHandler.onFault(MediatorFaultHandler.java:95)
at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:53)
at org.apache.synapse.endpoints.AbstractEndpoint.invokeNextFaultHandler(AbstractEndpoint.java:691)
at org.apache.synapse.endpoints.AbstractEndpoint.onFault(AbstractEndpoint.java:530)
at org.apache.synapse.endpoints.HTTPEndpoint.onFault(HTTPEndpoint.java:66)
at org.apache.synapse.FaultHandler.handleFault(FaultHandler.java:101)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.handleMessage(SynapseCallbackReceiver.java:285)
at org.apache.synapse.core.axis2.SynapseCallbackReceiver.receive(SynapseCallbackReceiver.java:188)
at org.apache.synapse.transport.passthru.TargetErrorHandler$1.run(TargetErrorHandler.java:139)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: javax.xml.stream.XMLStreamException
at org.apache.synapse.commons.staxon.core.base.AbstractXMLStreamReader.initialize(AbstractXMLStreamReader.java:245)
at org.apache.synapse.commons.staxon.core.json.JsonXMLStreamReader.<init>(JsonXMLStreamReader.java:66)
at org.apache.synapse.commons.staxon.core.json.JsonXMLInputFactory.createXMLStreamReader(JsonXMLInputFactory.java:165)
at org.apache.synapse.commons.json.JsonUtil.getReader(JsonUtil.java:333)
at org.apache.synapse.commons.json.JsonUtil.getReader(JsonUtil.java:315)
at org.apache.synapse.commons.json.JsonUtil.toXml(JsonUtil.java:294)
... 25 more
Can you try changing the default JSON builder and formatter pair in < APIM_HOME >/repository/conf/axis2/axis2.xml file to following:
<messageBuilder contentType="application/json" class="org.apache.axis2.json.JSONStreamBuilder>
<messageFormatter contentType="application/json" class="org.apache.axis2.json.JSONStreamFormatterā/>
Restart the server after changing. https://docs.wso2.com/display/AM210/Transforming+API+Message+Payload#TransformingAPIMessagePayload-JSONmessagebuildersandformatters
I am getting below exception while connecting to pipeline debugger. I tried to re start application server / HTTP service / system as well but no luck. Any one have faced the same problem .
com.intershop.beehive.core.rapi.soap.ConnectException:
http://localhost:80/INTERSHOP/servlet/WFS/SOAP/-/SessionMgmtService;
nested exception is:
com.intershop.beehive.core.rapi.soap.SOAPException: SOAP-Stub:
response payload is not wellformed at
com.intershop.beehive.core.rapi.soap.SOAPStub.getPayload(SOAPStub.java:381)
at
com.intershop.beehive.core.internal.bos.session.SessionMgmtService_SOAPStub.setTimeout(SessionMgmtService_SOAPStub.java:130)
at
com.intershop.studio.server.suite6.remote.emc.Session.(Session.java:111)
at
com.intershop.studio.server.suite6.remote.RemoteSuite6ServerInstance.doConnect(RemoteSuite6ServerInstance.java:113)
at
com.intershop.studio.server.remote.services.impl.AbstractRemoteServerInstance$1.run(AbstractRemoteServerInstance.java:52)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56) Caused
by: com.intershop.beehive.core.rapi.soap.SOAPException: SOAP-Stub:
response payload is not wellformed at
com.intershop.beehive.core.rapi.soap.SOAPStub.getPayload(SOAPStub.java:368)
... 5 more
I have a spring-boot application which is monitored by monit.
Monit just check the /health endpoint spring is exposing.
Basically, monit registered the following checks :
check host hopsearch_connection with address 127.0.0.1
if failed url http://127.0.0.1:8089/health with timeout 15 seconds then alert
check host hopsearch_health with address 127.0.0.1
if failed url http://127.0.0.1:8089/health
and content != 'DOWN'
with timeout 60 seconds
then alert
and the web application return something like that :
{"status":"UP","jestHealth":{"status":"UP","lastQuerySuccess":true},"diskSpace":{"status":"UP","free":14439550976,"threshold":10485760},"rabbit":{"status":"UP","version":"3.3.2"},"redis":{"status":"UP","version":"3.0.0"},"mongo":{"status":"UP","version":"2.6.1"}}
In this spring application, I have a general #ExceptionHandler to log all unexpected errors and to display an error page :
#ExceptionHandler(Exception.class)
#ResponseStatus(value = HttpStatus.INTERNAL_SERVER_ERROR)
public String handleDefaultError(Exception ex, HttpServletRequest httpRequest) {
logException(httpRequest, ex);
return "error";
}
And this #ExceptionHandler logs every call from monit :
<11>May 1 13:20:39 IP 13:20:39.339 t=http-nio-8089-exec-3 l=ERROR c=c.h.s.w.c.ErrorManager m=Error 500
----------------------------------------------------------------
Request Path=http://127.0.0.1:8089/health
Method=GET
----------------------------------------------------------------
Header :
----------------------------------------------------------------
host = 127.0.0.1:8089
accept = */*
connection = close
user-agent = monit/5.4
----------------------------------------------------------------
<11>May 1 13:20:39 IP 13:20:39.340 t=http-nio-8089- exec-3 l=ERROR c=c.h.s.w.c.ErrorManager m=Unexpected error : java.io.IOException: Broken pipe
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.8.0_25]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.8.0_25]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.8.0_25]
at sun.nio.ch.IOUtil.write(IOUtil.java:65) ~[na:1.8.0_25]
From monit perspective, everything is fine and the check works.
From my perspective, the application works. But I have a lot of errors dumped in the log.
I don't succeed to reproduce on my workstation with curl. This exception only happens on the server with monit.
Is it possible to ignore an error based on a specific user agent in an ExceptionHandler ? (and how ?)
It wouldn't be the best solution but I don't see any other way.
Any thoughts about that ?