-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traefik stuck when used as frontend for a streaming API #560
Comments
@git-oca currently, traefik supports streaming if mime type is set to |
Thanks for your reply Emile, Unfortunately, I have got exactly the same result using the "text/event-stream" mime type. so without traefik, I got the numbers (I used -i to be sure that the content type 'text/event-stream' was correct):
but with traefik as frontend, curl doesn't show up any number and seems stuck.
but I can see on the python server log that it is actually writing the response. |
Not sure if this helps, but just did a quick try with "oxy" alone as a reverse proxy and the streaming went fine... but still unable to get it working with traefik package main
import (
"net/http"
"github.com/vulcand/oxy/forward"
"github.com/vulcand/oxy/testutils"
)
func main() {
// Forwards incoming requests to whatever location URL points to, adds proper forwarding headers
fwd, _ := forward.New()
redirect := http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
// let us forward this request to another server
req.URL = testutils.ParseURI("http://localhost:8085")
fwd.ServeHTTP(w, req)
})
// that's it! our reverse proxy is ready!
s := &http.Server{
Addr: ":8080",
Handler: redirect,
}
s.ListenAndServe()
} |
@git-oca, this PR containous/oxy#9 fixed Mime Type parsing in containous/oxy. I will integrate it into traefik soon. |
Fantastic ! thank you very much ! 👍 |
Hi Emile, |
In oxy/forward/responseflusher.go, in func (wf *responseFlusher) Flush() {
flusher, ok := wf.ResponseWriter.(http.Flusher)
if ok {
flusher.Flush()
}
} ok seems to be always false when I'm streaming... unfortunately I don't know that much of Go... so I can't help that much more... désolé |
@git-oca you mean you built traefik using the commit |
I just cloned the master of traefik and modified oxy files manualy
|
I will post my toml by next week. I can also provide a docker image to help reproduce the problem
|
So here is my traefik.toml
and this is rules.toml
|
I just pushed on dockerhub an image that may help to reproduce the problem. every thing for testing is in the /oca folder. Now here are the steps to reproduce the problem. Let's first start the container You will need a few shell to start all the process. so I use docker exec -it f167dc33a2cd /bin/bash to start them Step 1 : starting the python web app that will do the streaming
Step 2: starting traefik to redirect 80 to 8085 Step 3 : testing docker@oca:~$ docker exec -it f167dc33a2cd /bin/bash root@f167dc33a2cd:/go# curl localhost:8085/numbers | head -n 10 Ok, without using a proxy, we got our numbers. Now try with traefik as a reverse proxy : Now if you :
you should see the numbers... |
@git-oca Could you try using Docker image |
I copied the binary traefik file of "containous/traefik:pr-584" to my container, did the test again and got the same result. root@79ee253dd695:/oca# ./traefik version |
I just put a few trace in each traefik/middlewares, in the ServeHTTP function. func (retry *Retry) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
_,ok := rw.(http.Flusher)
fmt.Println("retry.go, has flusher : ",ok)
...
} and here is what I got : handlerSwitcher.go, has flusher : true so it seems that the RequestWriter can no longer be typed as a http.Flusher after the "retry" middleware... |
very dirty, but just for a quick test, in retry.go, I replaced |
@git-oca: ouch, I think I got it... The |
Just tested that, but adding a Flush seems to be not enough...
but still no answer... so I think we should change Write too... cause it tries to copy to a buffer and that will never end... |
but we are close ;) |
just tested PR 592 , but it's not enough |
Added a call to |
defer rw.Flush() never get called... |
In fact |
ok got it, ResponseRecorder.Flush() is actually called... |
Funny way to learn GO BTW ;) |
@git-oca I just updated the PR, if you want to test :) |
@emilevauge 💯 That's it ! streaming is working fine with this version ! Thank you very much ! I just noticed that log after the request completed, but that don't seems to cause trouble :
Also something I don't care at all but that I noticed while looking in the code... so just to let you know, in server.go, there is an import of "github.com/codegangsta/negroni" that should now be "github.com/urfave/negroni" according to what they say on the project main page :
So thanks again ! Traefik is now replacing haproxy in our mesos cluster here in the localization team at Autodesk. |
Yeah, I know, but it will be difficult to avoid that here as
I will change that later, not in a bug fix release ;) |
…ve as Traefik backend. See traefik/traefik#560 for details. Bump to 1.1.
Hi, I have a service that streams potentially large responses, in a streaming fashion.
When I put traefik (v1.0.1) in front of my service, the streaming API doesn't seems to reply anymore.
My real use case is to do streaming on a SolR server that may have very large result-set.
but this small service (Python/Flask) will help to reproduce the problem easily :
A call to this '/numbers' API will generate an infinite stream of numbers.
This command, while doing a broken pipe, will however still reply and print number 0 to 9 :
When I'm using traefik as a reverse proxy to redirect call on port 80 to 8080, the '/numbers' API doesn't reply anymore.
(no response here...)
So is there anything that can be done about that ?
Thanks
Olivier
The text was updated successfully, but these errors were encountered: