Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Correcting error 405 when hosting on linux distro #235

Open
Azbests opened this issue Mar 15, 2019 · 9 comments
Open

Correcting error 405 when hosting on linux distro #235

Azbests opened this issue Mar 15, 2019 · 9 comments

Comments

@Azbests
Copy link

Azbests commented Mar 15, 2019

I'm running into problem of server returning "405 Method now allowed" when trying to push nupgk to server. I there any way to correct this on linux hosted server? So far typical suggestions like in Issue #195 of adding more configuration in web.config file have not helped so far.

Server running on debian stretch. Tried both docker version and just running with dotnet BaGet.dll.

Any suggestions?

@loic-sharma
Copy link
Owner

Are you using the default configuration (SQLite database and local filesystem)? I'm not sure how to best debug this... Could you try raising the LogLevel to Debug on your appsettings.json file. Please attach the logs to this issue (make sure there's no sensitive information in your logs!)

Also, have you tried attaching a debugger and stepping through the code? You'll want to set a breakpoint here: https://github.com/loic-sharma/BaGet/blob/master/src/BaGet.Core.Server/Controllers/PackagePublishController.cs#L40

@WernerMairl
Copy link
Contributor

HowTo Tracing

assuming that you have access to the console and that you are using a modified version of the original "appsettings.json", you can modify the following section:

    "Console": {
      "LogLevel": {
        "Default": "Warning",
        "Microsoft.AspNetCore.Routing": "Trace"
      }
    }

The last settings enables full TRACE but onlY for the routing engine.
if you change the "default" setting into
"Default": "Trace",
then you get the full blown aspnet Core Trace.....

You can do the same WITHOUT changing appsettings.json
by setting some environment variable (used specially on hosting environments like Azure AppService etc....

On Linux (VM or container) define a environment variable
Name=Logging__Console__LogLevel__Microsoft.AspNetCore.Routing
Value="Trace"

Important to know:

  • the name represents the Json hierarchy from appsettings.json
  • on linux you must use double underscores (!!!) "__" to separate Items, on Windows you can use ":"

@Azbests
Copy link
Author

Azbests commented Mar 18, 2019

Yes. I am using mostly default settings, only changed ApiKey and Storage path. And launched via "ASPNETCORE_URLS="http://*:5000" dotnet BaGet.dll" for now. Plan was to later on was to rely on nginx reverse proxying baget.

Log and settings attached below. Now sure if app startup part is required, but if needed will append to this reply.

Haven't tried to debug any deeper than looking for various solutions via google. Don't know if other approach for me would be any good as I'm not familiar with C# and I tinker in code only on automation tool level and some smaller apps.

appsetting.json

{
  "ApiKey": "derpderp",
  "PackageDeletionBehavior": "Unlist",
  "AllowPackageOverwrites": false,

  "Database": {
    "Type": "Sqlite",
    "ConnectionString": "Data Source=baget.db"
  },

  "Storage": {
    "Type": "FileSystem",
    "Path": "/home/krisjanis/packages"
  },

  "Search": {
    "Type": "Database"
  },

  "Mirror": {
    "Enabled": false,
    "PackageSource": "https://api.nuget.org/v3/index.json"
  },

  "Logging": {
    "IncludeScopes": false,
    "Debug": {
      "LogLevel": {
        "Default": "Debug"
      }
    },
    "Console": {
      "LogLevel": {
        "Default": "Debug",
        "Microsoft.AspNetCore.Routing": "Trace"
      }
    }
  }
}

web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <location path="." inheritInChildApplications="false">
    <system.webServer>
      <validation validateIntegratedModeConfiguration="false" />
      <modules runAllManagedModulesForAllRequests="true">
        <remove name="WebDAVModule" />
        <remove name="WebDAV" />
      </modules>
      <aspNetCore processPath="dotnet" arguments=".\BaGet.dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" />
    </system.webServer>
  </location>
</configuration>
<!--ProjectGuid: 284366CB-C68F-473E-908A-50A382616AE0-->

debug - response to put request.

info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
      Request starting HTTP/1.1 PUT http://192.168.122.217:5000/v3/index.json multipart/form-data; boundary=---------------------------8d6ab9e664342d7 5413
dbug: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0]
      Wildcard detected, all requests with hosts will be allowed.
trce: Microsoft.AspNetCore.HostFiltering.HostFilteringMiddleware[0]
      All hosts are allowed.
dbug: Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware[1]
      PUT requests are not supported
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1001]
      1 candidate(s) found for the request path '/v3/index.json'
dbug: Microsoft.AspNetCore.Routing.Matching.DfaMatcher[1005]
      Endpoint '405 HTTP Method Not Supported' with route pattern '(none)' is valid for the request path '/v3/index.json'
dbug: Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware[1]
      Request matched endpoint '405 HTTP Method Not Supported'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0]
      Executing endpoint '405 HTTP Method Not Supported'
info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1]
      Executed endpoint '405 HTTP Method Not Supported'
dbug: Microsoft.AspNetCore.Server.Kestrel[9]
      Connection id "0HLLBHMHQFNT2" completed keep alive response.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 64.7363ms 405 
dbug: Microsoft.AspNetCore.Server.Kestrel[25]
      Connection id "0HLLBHMHQFNT2", Request id "0HLLBHMHQFNT2:00000001": started reading request body.
info: Microsoft.AspNetCore.Server.Kestrel[32]
      Connection id "0HLLBHMHQFNT2", Request id "0HLLBHMHQFNT2:00000001": the application completed without reading the entire request body.
dbug: Microsoft.AspNetCore.Server.Kestrel[26]
      Connection id "0HLLBHMHQFNT2", Request id "0HLLBHMHQFNT2:00000001": done reading request body.

@WernerMairl
Copy link
Contributor

WernerMairl commented Mar 18, 2019

i had only a few minutes today...but 2 ideas:

maybe the same problem like here:
https://stackoverflow.com/questions/16451183/405-method-not-allowed-in-nuget-push

OR:

the Method "Upload" inside the PackagePublishController has NO Http Attribute....
may be for some bug/implicit solution the "PUT" is not recognized ?

we should doublecheck if we should add a [HttpPut] attribute there....

BUT basically push on linux should be working, i was able to push on my demo instance (Azure Linux WebApp docker container) yesterday.....
syntax: nuget push %nupkg% -source "https://bagetbasic.azurewebsites.net/v3/index.json"

Werner

@Azbests
Copy link
Author

Azbests commented Mar 18, 2019

Found my problem. Packet client for some reason when using apikey throws out this 405 error. Same thing if choco.exe (chocolatey nuget client) is used.

PS D:\nuget> .\paket.exe push --url "http://192.168.122.217:5000/v3/index.json" --api-key "derpderp" winbox.3.18.2.nupkg
Paket version 5.198.0
Pushing package winbox.3.18.2.nupkg to http://192.168.122.217:5000/v3/index.json - trial 1
Could not push winbox.3.18.2.nupkg: The remote server returned an error: (405) Method Not Allowed.
Pushing package winbox.3.18.2.nupkg to http://192.168.122.217:5000/v3/index.json - trial 2
Could not push winbox.3.18.2.nupkg: The remote server returned an error: (405) Method Not Allowed.
Pushing package winbox.3.18.2.nupkg to http://192.168.122.217:5000/v3/index.json - trial 3
Could not push winbox.3.18.2.nupkg: The remote server returned an error: (405) Method Not Allowed.
Pushing package winbox.3.18.2.nupkg to http://192.168.122.217:5000/v3/index.json - trial 4
Could not push winbox.3.18.2.nupkg: The remote server returned an error: (405) Method Not Allowed.
Pushing package winbox.3.18.2.nupkg to http://192.168.122.217:5000/v3/index.json - trial 5
Performance:
 - Runtime: 571 milliseconds
Paket failed with
-> WebException: The remote server returned an error: (405) Method Not Allowed.
PS D:\nuget> choco.exe push winbox.3.18.2.nupkg --source "http://192.168.122.217:5000/v3/index.json" --api-key="derpderp" --force
Chocolatey v0.10.11
Attempting to push winbox.3.18.2.nupkg to http://192.168.122.217:5000/v3/index.json
Failed to process request. 'Method Not Allowed'.
The remote server returned an error: (405) Method Not Allowed..

When I push from nuget.exe with no apikey or previously saved credentials all works fine. Just need to save credentials before that or while pushing it will ask both user and password. And I couldn't find default used user value.

I guess I was looking for problem in wrong direction previously. Probably I should change title of issue. As that could point some one in the future the wrong way too.

@arnydo
Copy link

arnydo commented Mar 20, 2019

Receiving the same error on Win10. No modifications to config.

publish-module -Name PS-CoolModuleIMade -Repository TestBaGET -NuGetApiKey $apikey
Publish-PSArtifactUtility : Failed to publish module 'PS-CoolModuleIMade': 'Failed to process request. 'Method Not Allowed'.
The remote server returned an error: (405) Method Not Allowed..
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1227 char:17
+                 Publish-PSArtifactUtility -PSModuleInfo $moduleInfo `
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToPublishTheModule,Publish-PSArtifactUtility

@loic-sharma
Copy link
Owner

loic-sharma commented Mar 31, 2019

@Azbests It looks like you'll need to use the following command to push your package using Paket:

.\paket.exe push --url http://192.168.122.217:5000 --api-key "derpderp" winbox.3.18.2.nupkg

This is awful confusing, I've went ahead and suggested some improvements to Paket: fsprojects/Paket#3322 (comment).

@arnydo I see that @tomzo figured out the issue for publish-module here: ai-traders/liget#14 (comment)

I'll add better instructions to BaGet's documentation and "Upload" page.

@loic-sharma
Copy link
Owner

loic-sharma commented Mar 31, 2019

I've improved the documentation on the Upload page, please let me know what you think! See: #247 and release v0.1.75-prerelease

@bahram-ghahari
Copy link

I'm having the same issue on my linux machine.

dotnet nuget push -s http://localhost:50561/v3/index.json mypackage.1.0.0.nupkg Failed to process request. 'Method Not Allowed'. The remote server returned an error: (405) Method Not Allowed.

I changed the logging level and this is what it shows

info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint '405 HTTP Method Not Supported' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint '405 HTTP Method Not Supported'

which I assume points to http://localhost:50561/api/v2/package and http://localhost:50561/api/v2/symbol.
During debuging I realized that it doesn't hit the breakpoint in PackagePublishController.Upload(CancellationToken).

Could (https://docs.microsoft.com/en-us/nuget/api/nuget-protocols) be the reason?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants