Skip to content
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

feat: Add Proxy Support to Fasthttp client #40

Closed
rabilrbl opened this issue Sep 16, 2023 · 16 comments · Fixed by #49
Closed

feat: Add Proxy Support to Fasthttp client #40

rabilrbl opened this issue Sep 16, 2023 · 16 comments · Fixed by #49
Labels
enhancement New feature or request

Comments

@rabilrbl
Copy link
Owner

rabilrbl commented Sep 16, 2023

Description

Addition of proxy support to Fasthttp library for HTTP requests.

Proposed Solution

To enable proxy support, we can explore the following steps:

  1. Identify the specific use cases where proxy support is required.
  2. Evaluate the available proxy options and libraries that are compatible with Fasthttp.
  3. Implement proxy configuration and handling in our Go application.
  4. Test the proxy support thoroughly to ensure it works seamlessly with Fasthttp.
  5. Document the changes and update the README with instructions on how to configure and use the proxy feature.
@github-actions github-actions bot added bug Something isn't working enhancement New feature or request ui labels Sep 16, 2023
@rabilrbl rabilrbl removed ui bug Something isn't working labels Sep 16, 2023
@github-actions github-actions bot added the bug Something isn't working label Sep 16, 2023
@rabilrbl rabilrbl removed the bug Something isn't working label Sep 16, 2023
@spacex97
Copy link
Contributor

Hi
I tested it just now and its giving me error, 59100 is my proxy port.
television.go:246: strconv.Atoi: parsing "59100\"": invalid syntax panic: strconv.Atoi: parsing "59100\"": invalid syntax

@rabilrbl rabilrbl linked a pull request Sep 22, 2023 that will close this issue
@rabilrbl
Copy link
Owner Author

rabilrbl commented Sep 22, 2023

Hi I tested it just now and its giving me error, 59100 is my proxy port. television.go:246: strconv.Atoi: parsing "59100\"": invalid syntax panic: strconv.Atoi: parsing "59100\"": invalid syntax

Can you send me complete logs? and web page screenshot if possible.
Also please tell how did u set environment variable with a dummy example

@spacex97
Copy link
Contributor

Hi
Can we discuss on telegram @ https://t.me/G0ku95 or discord @ shinigami007 if possible since proxy works fine in my python client.

2023/09/22 22:02:50 television.go:246: strconv.Atoi: parsing "59100\"": invalid syntax panic: strconv.Atoi: parsing "59100\"": invalid syntax goroutine 35 [running]: runtime/debug.Stack() C:/Program Files/Go/src/runtime/debug/stack.go:24 +0x5e github.com/gofiber/fiber/v2/middleware/recover.defaultStackTraceHandler(0x52786a?, {0x905380, 0xc000086540}) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:12 +0x25 main.main.New.func1.1() C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:31 +0x72 panic({0x905380?, 0xc000086540?}) C:/Program Files/Go/src/runtime/panic.go:914 +0x21f log.(*Logger).Panic(0xc0000b6500?, {0xc00026f708?, 0x8?, 0x4c9693?}) C:/Program Files/Go/src/log/log.go:303 +0x65 github.com/rabilrbl/jiotv_go/internals/television.Channels() C:/Users/Adi/Desktop/jiotv_go-feat-proxysupport/internals/television/television.go:246 +0x505 github.com/rabilrbl/jiotv_go/internals/handlers.IndexHandler(0x922e60?) C:/Users/Adi/Desktop/jiotv_go-feat-proxysupport/internals/handlers/handlers.go:43 +0x2a github.com/gofiber/fiber/v2.(*App).next(0xc00013f400, 0xc0000a6000) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/router.go:145 +0x1b2 github.com/gofiber/fiber/v2.(*Ctx).Next(0xc00009a2aa?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/ctx.go:970 +0x4d main.main.CORS.func2(0x1?) C:/Users/Adi/Desktop/jiotv_go-feat-proxysupport/internals/middleware/cors.go:16 +0xa5 github.com/gofiber/fiber/v2.(*Ctx).Next(0x8104bc?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/ctx.go:967 +0x3d main.main.New.func1(0x922e60?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:43 +0xbb github.com/gofiber/fiber/v2.(*App).next(0xc00013f400, 0xc0000a6000) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/router.go:145 +0x1b2 github.com/gofiber/fiber/v2.(*App).handler(0xc00013f400, 0x5475af?) C:/Users/Adi/go/pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/router.go:172 +0x78 github.com/valyala/fasthttp.(*Server).serveConn(0xc00025a000, {0xadec98?, 0xc0002901b8}) C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/server.go:2359 +0x11d4 github.com/valyala/fasthttp.(*workerPool).workerFunc(0xc0002840a0, 0xc00028e7e0) C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/workerpool.go:224 +0xa4 github.com/valyala/fasthttp.(*workerPool).getCh.func1() C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/workerpool.go:196 +0x32 created by github.com/valyala/fasthttp.(*workerPool).getCh in goroutine 1 C:/Users/Adi/go/pkg/mod/github.com/valyala/fasthttp@v1.50.0/workerpool.go:195 +0x1ab

Screenshot 2023-09-22 230436

@rabilrbl
Copy link
Owner Author

So far the bug is only found in windows, looks like fasthttpproxy has some issues with Windows.

@spacex97
Copy link
Contributor

@rabilrbl thanks you very much for support, issue persist with windows only and work fine in linux, we just need to proxify ts file too so that it stream without any issue

@rabilrbl
Copy link
Owner Author

@spacex97 Why proxify ts? What is it?
Why can't it just stream with gofiber routes?

@ragmehos
Copy link

@rabilrbl This works great, can we get it merged?

I was also checking, does fasthttp support https proxy types? I tried https proxy type and it doesnt seem to work.

@spacex97
Copy link
Contributor

there is no need for https proxy, most proxies are http in nature and support https out of the box

@rabilrbl
Copy link
Owner Author

rabilrbl commented Sep 24, 2023

@ragmehos as said by @spacex97
All proxy types are supported.
Conditions:

  • it must be indian ip
  • ISP of proxy shouldn't be from popular cloud provider as JioTV API blocks

@ragmehos
Copy link

ragmehos commented Sep 24, 2023

@rabilrbl That's interesting, I tried to use a https proxy, and it fails saying "the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection"

television.go:276: the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection panic: the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection goroutine 18 [running]: runtime/debug.Stack() versions/1.21.1/src/runtime/debug/stack.go:24 +0x64 github.com/gofiber/fiber/v2/middleware/recover.defaultStackTraceHandler(0x102e739c0?, {0x102aa4fe0, 0x14000322000}) pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:12 +0x24 main.main.New.func1.1() pkg/mod/github.com/gofiber/fiber/v2@v2.49.2/middleware/recover/recover.go:31 +0x70 panic({0x102aa4fe0?, 0x14000322000?}) versions/1.21.1/src/runtime/panic.go:914 +0x218 log.(*Logger).Panic(0x140002b8000?, {0x140002196c8?, 0x8?, 0x1025834b0?}) versions/1.21.1/src/log/log.go:303 +0x68 github.com/rabilrbl/jiotv_go/internals/television.Channels() internals/television/television.go:276 +0x4c4

I verified that this proxy works with the https://jiotv.data.cdn.jio.com..... url and it lists it fine.

@rabilrbl rabilrbl reopened this Sep 24, 2023
@rabilrbl
Copy link
Owner Author

@ragmehos likely because your proxy timeout is high, what's the timeout?

@ragmehos
Copy link

ragmehos commented Sep 24, 2023

@ragmehos likely because your proxy timeout is high, what's the timeout?

Doesn't seem to be related to the timeout, it happens immediately, also happens if I set the timeout to be low. I tried two https proxies from two different vpns, both of them run into the same error.

Also, let's say the access token is expired and I launch the binary with a proxy, it fails immediately when trying to route via the proxy to refresh the token.

http proxy on the other hand works fine, no issues, not sure what it is with a https proxy - not sure if fasthttpproxy supports using a https proxy, I looked at the code, its not super clear.

@spacex97
Copy link
Contributor

there are many things that do not work with https proxy even with my python scripts, u need to set verify as false but again if http works fine what is pushing you to use https.
Now I am more interested in your use case as http proxies are widely available as compared to https.

@ragmehos
Copy link

Most of the proxies I have are https, only one of them is http, so I just want to get it working with the https proxy too so that there are alternatives for me, in case the http proxy gets blocked.

@rabilrbl
Copy link
Owner Author

rabilrbl commented Sep 25, 2023

@ragmehos the only way, I can debug this is with your proxy. Give me temporary access to proxy. Post a message in Telegram group with your GitHub username, I'll message you private. Or If you understand Go, you can debug yourself and make a PR.

@rabilrbl
Copy link
Owner Author

@ragmehos Closing this issue as it is not relevant here. Please create a new issue bug at https://github.com/rabilrbl/jiotv_go/issues/new?assignees=&labels=bug&projects=&template=bug_issue.yml&title=bug%3A+

Repository owner locked as resolved and limited conversation to collaborators Sep 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants