{"record":{"id":"cefba20e2341e88d","repo":"yudai/gotty","slug":"method-not-allowed","errorCode":null,"errorMessage":"Method not allowed","messagePattern":"Method not allowed","errorType":"http","errorClass":null,"httpStatus":405,"severity":"error","filePath":"server/handlers.go","lineNumber":64,"sourceCode":"\t\t\t\tcloseReason, r.RemoteAddr, num, server.options.MaxConnection,\n\t\t\t)\n\n\t\t\tif server.options.Once {\n\t\t\t\tcancel()\n\t\t\t}\n\t\t}()\n\n\t\tif int64(server.options.MaxConnection) != 0 {\n\t\t\tif num > server.options.MaxConnection {\n\t\t\t\tcloseReason = \"exceeding max number of connections\"\n\t\t\t\treturn\n\t\t\t}\n\t\t}\n\n\t\tlog.Printf(\"New client connected: %s, connections: %d/%d\", r.RemoteAddr, num, server.options.MaxConnection)\n\n\t\tif r.Method != \"GET\" {\n\t\t\thttp.Error(w, \"Method not allowed\", 405)\n\t\t\treturn\n\t\t}\n\n\t\tconn, err := server.upgrader.Upgrade(w, r, nil)\n\t\tif err != nil {\n\t\t\tcloseReason = err.Error()\n\t\t\treturn\n\t\t}\n\t\tdefer conn.Close()\n\n\t\terr = server.processWSConn(ctx, conn)\n\n\t\tswitch err {\n\t\tcase ctx.Err():\n\t\t\tcloseReason = \"cancelation\"\n\t\tcase webtty.ErrSlaveClosed:\n\t\t\tcloseReason = server.factory.Name()\n\t\tcase webtty.ErrMasterClosed:","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/yudai/gotty/blob/a080c85cbc59226c94c6941ad8c395232d72d517/server/handlers.go#L46-L82","documentation":"Plain 405 response from the WS handler guard: the HTTP method of the upgrade request is not GET, which is required by the websocket handshake, so the connection is rejected before any upgrade or auth is attempted.","triggerScenarios":"Thrown at server/handlers.go:64 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send websocket upgrade requests as GET only","Fix client code accidentally POST/PUT-ing to the ws URL","Check for proxies rewriting the method in front of the server"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a080c85cbc59226c94c6941ad8c395232d72d517","analyzedAt":"2026-09-02T16:42:38.150Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}