Comments (4)
http-kit reuses the AsyncChannel object. AsyncChannel is per connection. A connection is a TCP connection. Since browser or JMeter will try to use the TCP connection, AsyncChannel get reused. When reused, AsyncChannel get reseted https://github.com/http-kit/http-kit/blob/master/src/java/org/httpkit/server/AsyncChannel.java#L73
Since the reset is lazyset, maybe this is where the problem is.
http-kit only allow set the closeHandler once, maybe this is a bad design. How do you think about it?
As regarding the multiple threads, how about this:
Do not use PipedInputStream or PipedOutputStream. Instead of write to the PipedOutputStream, just write to channel. http-kit is multi-threaded, blocking a few thread will be fine. Set :thread
option to a larger value will be fine http://http-kit.org/server.html#options
from http-kit.
This helped so much! Thank you, @shenfeng.
As for only allowing the closeHandler once, I think it's ok, although it is confusing since the reset is lazyset and you can encounter a situation where you think the closeHandler is not set but it actually is.
When you say "just write to channel," what do you mean, exactly? I am generating a stream of JSON or XML text and need an OutputStream for it to go into. The channel's not an OutputStream, so I'm not certain the best way to go about that.
from http-kit.
I will try to reproduce and fix the issue with closeHandler, It maybe a multi thread bug of http-kit.
The channel's not an OutputStream
You can create a method, like:
ch->outputstream
(defn ch->outputstream [ch]
(proxy [java.io.OutputStream] []
(close []
)
(write
([bs] ;; bytes of byte
;; write to channel
)
([^bytes bs off len]
))))
from http-kit.
Hi, I look at the code carefully, the reset
is threadsafe, should ok.
Can you help by show test case to reproduce the problem?
from http-kit.
Related Issues (20)
- Race condition in TimerService.scheduleTask HOT 2
- Ring websocket API support HOT 4
- Problem in native-image and HttpUtils when using virtual threads HOT 11
- 2.8.0-beta2 has CIDER dependencies HOT 3
- CURL and finagle failing to parse :set-cookies with '\n' HOT 13
- Unix socket benchmark HOT 1
- It will turn headers into camel format HOT 2
- logger-warn gets rebound HOT 1
- logger-warn and error-warn are passed in wrong order to HttpServer constructor HOT 1
- Requests which throw java.net.ConnectException may actually succeed HOT 3
- Request Map doesn't contain information about authority HOT 8
- http-kit v2.8.0-RC1 HOT 1
- http-kit v2.8.0 final HOT 1
- Consider adding `Content-Type: text/plain` to HTTP 500 response in `org.httpkit.server.HttpHandler#run` HOT 6
- v2.7.0 SNI change broke connections to plain IP addresses with SSLHandshakeException "Hostname or IP address is undefined." HOT 8
- Add options for encoding nested form and query params a la clj-http HOT 7
- WebTransport support HOT 2
- NoSuchMethodError on projects AOT'd on java 21 but run on earlier java versions HOT 13
- [Proposal][Client] Consider more idiomatic bridges with JVM async paradigms HOT 5
- "Unmasked client to server frame" causes 502s HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from http-kit.