{"record":{"id":"d91747eef583addb","repo":"shadow1ng/fscan","slug":"connection-timeout","errorCode":null,"errorMessage":"connection_timeout","messagePattern":"connection_timeout","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/services/smb_protocol.go","lineNumber":458,"sourceCode":"\t\t\t\tError:     fmt.Errorf(\"%s\", i18n.GetText(\"service_auth_failed\")),\n\t\t\t}\n\t\t}\n\t}()\n\n\tselect {\n\tcase result := <-resultChan:\n\t\treturn result, nil\n\tcase <-timeoutCtx.Done():\n\t\tgo func() {\n\t\t\tresult := <-resultChan\n\t\t\tif result != nil && result.Conn != nil {\n\t\t\t\t_ = result.Conn.Close()\n\t\t\t}\n\t\t}()\n\t\treturn &AuthResult{\n\t\t\tSuccess:   false,\n\t\t\tErrorType: ErrorTypeNetwork,\n\t\t\tError:     fmt.Errorf(\"%s\", i18n.GetText(\"connection_timeout\")),\n\t\t}, nil\n\tcase <-ctx.Done():\n\t\tgo func() {\n\t\t\tresult := <-resultChan\n\t\t\tif result != nil && result.Conn != nil {\n\t\t\t\t_ = result.Conn.Close()\n\t\t\t}\n\t\t}()\n\t\treturn &AuthResult{\n\t\t\tSuccess:   false,\n\t\t\tErrorType: ErrorTypeNetwork,\n\t\t\tError:     ctx.Err(),\n\t\t}, nil\n\t}\n}\n\n// ListShares 列举SMB共享（SMB1使用SMB2库列举）\nfunc (a *SMB1Authenticator) ListShares(ctx context.Context, host string, port int, cred Credential, domain string, timeout time.Duration, session *common.ScanSession) ([]string, error) {","sourceCodeStart":440,"sourceCodeEnd":476,"githubUrl":"https://github.com/shadow1ng/fscan/blob/95cc12e753bf43de7004e5aef42a9ffba3934303/plugins/services/smb_protocol.go#L440-L476","documentation":"The SMB authentication attempt exceeded its configured timeout. Authenticate selects on a timer channel and returns an ErrorTypeNetwork result with a localized 'connection_timeout' message, closing the result connection in a background goroutine. It indicates the remote host did not complete the SMB handshake in time.","triggerScenarios":"Calling Authenticate where the auth goroutine does not deliver a result before the timer fires; also returned when the caller-supplied context is cancelled (ctx.Done branch).","commonSituations":"Scanning slow or rate-limiting hosts; firewalls silently dropping SMB packets (port 445 filtered); overly aggressive timeout configuration; network congestion.","solutions":["Increase the timeout value in the scan/plugin configuration.","Verify port 445 is reachable (no silent firewall drop) with a TCP connect test.","Retry the target; transient latency or rate limiting often causes one-off timeouts.","Ensure the context passed to Authenticate has an adequate deadline and is not cancelled early."],"exampleFix":"// before\ncfg.SetTimeout(2 * time.Second)\n// after\ncfg.SetTimeout(15 * time.Second) // accommodate slow SMB negotiation","handlingStrategy":"retry","validationCode":"if cfg.Timeout() < 10*time.Second { cfg.SetTimeout(10 * time.Second) }","typeGuard":null,"tryCatchPattern":"res := plugin.Authenticate(ctx, conn, cred)\nif res.ErrorType == ErrorTypeNetwork {\n    // timeout: retry with backoff or skip unreachable host\n}","preventionTips":["Set generous timeouts for SMB negotiation (>=10s)","Pre-check TCP reachability of port 445 before auth","Retry timeouts once before marking host unreachable","Avoid cancelling the context prematurely"],"tags":["smb","timeout","network"],"backgroundTag":"request-timeout","analyzedSha":"95cc12e753bf43de7004e5aef42a9ffba3934303","analyzedAt":"2026-09-06T17:07:30.094Z","contentChangedAt":"2026-09-06T17:07:30.094Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}