mirror of
https://github.com/fatedier/frp.git
synced 2026-05-15 08:05:49 -06:00
[GH-ISSUE #2487] Exit if login fails while reconnecting #1972
Labels
No labels
In Progress
WIP
WaitingForInfo
bug
doc
duplicate
easy
enhancement
future
help wanted
invalid
lifecycle/stale
need-issue-template
need-usage-help
no plan
proposal
pull-request
question
todo
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/frp#1972
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jordemort on GitHub (Jul 19, 2021).
Original GitHub issue: https://github.com/fatedier/frp/issues/2487
I would like an option to make
frpcto exit when it fails to reconnect.login_fail_exitwould do this, but it does not.login_fail_exitdo this, but what I want is not actually the intended behavior oflogin_fail_exithttps://github.com/fatedier/frp/pull/2483I would add a new option (maybe
reconnect_login_fail_exit?) that would makefrpcexit when it fails to login while reconnecting.Application scenarios of this function
We need to authenticate our
frpcclients when they connect tofrps. We cannot use a single shared token for this purpose, and we do not want to maintain the infrastructure needed to support OIDC authentication. Instead, we have implemented our own authentication system using a server plugin for Login.We have a script that generates a JWT and stores it in the environment, and then starts
frpc. Ourfrpc.inicontains the following line:When the client tries to log in, the JWT is passed over to our server plugin, which validates it and allows the login to succeed.
However, the JWT is only valid for a short time. When
frpcattempts to reconnect, it uses the same JWT as when it was initially started. The JWT is now expired. Our server plugin rejects the login and our tunnel never comes back up, becausefrpcjust keeps trying with the same expired token.Instead of retrying forever, we would like a way to make
frpcexit when the login fails when reconnecting. Then our script can regenerate the JWT and restartfrpc, and it will be able to connect again.@jordemort commented on GitHub (Jul 19, 2021):
@fatedier - I am willing to try and make a PR to implement this, if you think it is something you would accept. My Go skills are not very sharp, but I think I can probably handle it.
@fatedier commented on GitHub (Jul 20, 2021):
It's not an elegant way to let frpc exit for each login fail reason such as network error or other temporary error.
I have considered add a paramter like
permanentErrorin LoginResponse so frpc can exit when it receives a permanent error. However, i still wonder if we should do that. In which scenarios users want to stop frpc or just keep it running. I think it's a strange behavior so i don't want to add this feature.What's your need seems a way to refresh token but we havn't provide this way. You key demand is not to stop frpc.
How about providing a new API to show frpc status so you can decide if stopping frpc.
Or maybe we should also consider to extend auth module.
@jordemort commented on GitHub (Jul 20, 2021):
Having a way for a login plugin to indicate
permanentError(do not try to reconnect) would be ideal for us. This would be even better thanreconnect_login_fail_exitfor our use case.I do not like this solution as much. The implementation would be much more complicated. We would need another piece of software that periodically checks
frpcand determines if it has failed due to an expired token. This introduces several other moving parts that might possibly fail (connecting to the API, properly processing the results, sending the restart signal.) Compare to our current solution, where we have a simple shell script that systemd restarts whenever it exits.If this does not allow for a
permanentErrorI don't understand how it would be much different from the existingLoginplugin.The assumption in the "reconnect forever" loop that I've violated with my plugin is that if login succeeded once, then login can succeed again using the same set of credentials. So
permanentErrorseems like the best solution to me, so that I can tellfrpc"no, stop trying, this will never work"@fatedier commented on GitHub (Jul 21, 2021):
I dont't want to change the architecture that frpc is a long running process and not exit until a manual stop or critical bug. This will add more complexity and it's not the fundamental demand.
We can try to support more auth methods to allow you refresh your tokens without restarting frpc itself. We can study more from other open sources to find a appropriate way.
@jordemort commented on GitHub (Jul 21, 2021):
@fatedier Hm, what if frpc had a client plugin interface, similar or even identical to the server plugin interface? frpc could pass requests to a plugin and the plugin could direct frpc to modify the request before sending it to the server. Then I could build a plugin that always supplies frpc with a fresh JWT.
@fatedier commented on GitHub (Jul 21, 2021):
It's an optional plan. I want to learn more about this field and dicuss later. Let this issue open to trace this proposal.
@jordemort commented on GitHub (Sep 13, 2021):
@fatedier Any further thoughts on enabling this? We're still carrying the custom patch from my old PR in our build.
@fatedier commented on GitHub (Nov 6, 2025):
Further updates will be tracked in https://github.com/fatedier/frp/issues/5045