Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Cannot access install.ps1 when accessing through a forwarded port #51

Open
jborean93 opened this issue Aug 6, 2018 · 0 comments
Open

Comments

@jborean93
Copy link
Contributor

When the Chocolatey server host is sitting behind a forwarded port, it may fail to access the install.ps1 script. When turning on more logging you would see the following error

<Error><Message>An error has occurred.</Message><ExceptionMessage>Unable to connect to the remote server</ExceptionMessage><ExceptionType>System.Net.WebException</ExceptionType><StackTrace>   at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
   at System.Net.WebClient.DownloadString(Uri address)
   at System.Net.WebClient.DownloadString(String address)
   at SimpleChocolateyServer.Contollers.InstallController.DownloadPowerShellInstallScript()
   at lambda_method(Closure , Object , Object[] )
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()</StackTrace><InnerException><Message>An error has occurred.</Message><ExceptionMessage>No connection could be made because the target machine actively refused it 127.0.0.1:8080</ExceptionMessage><ExceptionType>System.Net.Sockets.SocketException</ExceptionType><StackTrace>   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)</StackTrace></InnerException></Error>

This is due to the code at https://github.com/chocolatey/simple-server/blob/master/src/SimpleChocolateyServer/Controllers/InstallController.cs#L44 where the IIS service tries to access itself using the URL the client used. In the case of a forwarded port, this may not be a valid URL service side.

A simple example of this is if Choco server is on a Virtualbox where port 80 is forwarded to port 8080 on the VB host. I would access the Chocolatey URL with http://127.0.0.1:8080/install.ps1 and the code would then try and access http://127.0.0.1:8080/chocolatey/Packages()?$filter=((Id%20eq%20%27chocolatey%27)%20and%20(not%20IsPrerelease))%20and%20IsLatestVersion which may not be valid on that actual host. This is a pretty niche case but I thought it best to add an issue about it.

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

No branches or pull requests

1 participant