question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HTTP-Adapter: IllegalStateException: Response has already been written

See original GitHub issue

The HTTP adapter showed this error in the logs:

DEBUG VertxBasedHttpProtocolAdapter  failed to send http response for [EVENT] message from device [tenantId: test, deviceId: test_123]: response already closed
WARN  JaegerSpan  Span has already been finished; will not be reported again.
WARN  TracingHelper  An unexpected error occurred!
java.lang.IllegalStateException: Response has already been written
	at io.vertx.core.http.impl.Http1xServerResponse.end(Http1xServerResponse.java:394)
	at io.vertx.core.http.impl.Http1xServerResponse.end(Http1xServerResponse.java:382)
	at io.vertx.core.http.impl.Http1xServerResponse.end(Http1xServerResponse.java:451)
	at org.eclipse.hono.adapter.http.AbstractVertxBasedHttpProtocolAdapter.lambda$doUploadMessage$31(AbstractVertxBasedHttpProtocolAdapter.java:738)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
calohmncommented, Jul 7, 2022

Hi, I tried to reproduce it by adding to the request the following property hono-ttd (CASE 1) and I canceled the request before the hono-ttd expires, the result is that it does not enter into Line: 699 (.map(proceed -> {…)

So that means that the Future result from the preceding compose block isn’t getting succeeded. In fact, since the recover block below apparently isn’t entered as well (no cannot process message in your logs above), this Future isn’t completed at all, if the hono-ttd request is cancelled by the device.

I would have guessed that this could mean a memory leak, but according to some tests I’ve done here this doesn’t seem to be the case. Nonetheless I think this is something that should be corrected, letting the Future be completed when the request gets closed by the device prematurely.

In any case, the above tests seem to show that reproducing the error described in this issue isn’t that easy. My guess here would be that you would need to send a hono-ttd request and actually send a command message in response to that and then, while this block https://github.com/eclipse/hono/blob/5a3ae23bb73be5a5d123eba7f43447a0b6c7c58e/adapters/http-base/src/main/java/org/eclipse/hono/adapter/http/AbstractVertxBasedHttpProtocolAdapter.java#L685-L694 is being processed (i.e. while an unregister-cmd-consumer request is sent to the Command Router), the client has to cancel the request. In order to achieve this, it could help to add some delay (in the form of a vert.x timer execution) in the above block when testing this.

1reaction
sophokles73commented, Jun 17, 2022

Sure 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTP-Adapter: IllegalStateException: Response has already ...
The HTTP adapter showed this error in the logs: DEBUG VertxBasedHttpProtocolAdapter failed to send http response for [EVENT] message from ...
Read more >
Vertx throws IllegalStateException : Response has already ...
A handler is registered on the api endpoint which will write to the response. ... This answer is specific to exception "response has...
Read more >
Why am i getting "java.lang.IllegalStateException: Response ...
IllegalStateException : Response has already been written". private void getMetadataFromFileList(RoutingContext context) {. this.fileSystem.
Read more >
httpConnector Error Message is Displayed
When starting an application that refers to a httpConnector shared resource, an error is generated. java.lang.IllegalStateException: Cannot start endpoint ...
Read more >
www.cs.cmu.edu/afs/qatar.cmu.edu/system/src/host/t...
Realms: Refactor MemoryRealm and JDBCRealm so that common code is in a ... HttpConnector: It is now possible to disable lookups of the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found