-
Notifications
You must be signed in to change notification settings - Fork 114
Closed
Description
When using RunXrayFromJSON, the Xray core appears to be started twice, which results in a TCP port binding error.
Despite this error, Xray continues to work normally and accepts connections, but the function returns an error as if Xray failed to start. This makes it impossible for the caller to reliably determine whether Xray is actually running.
{
"success": false,
"error": "app/proxyman/inbound: failed to listen TCP on 14555 > transport/internet: failed to listen on address: 127.0.0.1:14555 > transport/internet/tcp: failed to listen TCP on 127.0.0.1:14555 > listen tcp 127.0.0.1:14555 : bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."
}
If coreServer.Start() is commented out, Xray starts and works correctly.
This suggests that StartXrayFromJSON(configJSON) already starts the core internally, and calling coreServer.Start() again causes a second attempt to bind to the same port.
Line 78 in 7ec81ad
| func RunXrayFromJSON(datDir string, configJSON string) (err error) { |
func RunXrayFromJSON(datDir string, configJSON string) (err error) {
InitEnv(datDir)
memory.InitForceFree()
coreServer, err = StartXrayFromJSON(configJSON)
if err != nil {
return
}
// This call causes a second start
if err = coreServer.Start(); err != nil {
return
}
debug.FreeOSMemory()
return nil
}
Environment
OS: Windows 11
Xray version: 25.12.8
Metadata
Metadata
Assignees
Labels
No labels