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

Could not connect to OmniSharp server; Errno 111 Connection Refused - Neovim 3.3 on WSL, Ubuntu 18.04 #445

Closed
Mantissa-23 opened this issue Jan 31, 2019 · 7 comments

Comments

@Mantissa-23
Copy link

Mantissa-23 commented Jan 31, 2019

I've been trying to get the latest version of Omnisharp-vim working with Roslyn 1.32.1 to no avail.

What I've tried:

  • Letting omnisharp-vim auto install to ~/.omnisharp. No success. Tried running ~/.omnisharp/omnisharp-roslyn/run -v; installed libuv1-dev. Still not working.
  • Manually installing 1.32.1 to C:\tools\Omnisharp\omnisharp\OmniSharp.exe, with:
Plug 'OmniSharp/omnisharp-vim'
let g:OmniSharp_server_path = '/mnt/c/tools/Omnisharp/omnisharp/OmniSharp.exe'
let g:OmniSharp_translate_cygwin_wsl = 1
let g:OmniSharp_proc_debug = 1
let g:OmniSharp_loglevel = 'debug'
  • Installing neovim 3.3 and python3 for Windows. Same errors.

I have tried reinstalling both options. Neither have worked. Unsure what the issue is; I've verified python3 is installed and working. The issue doesn't seem to be with omnisharp-vim, but with the server refusing http connections. Output of :OmniSharpOpenPythonLog:

2019-01-30 22:22:06,408 ERROR Could not connect to OmniSharp server: http://localhost:58151/updatebuffer
Traceback (most recent call last):
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/usr/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/dylan/.local/share/nvim/plugged/omnisharp-vim/python/omnisharp/util.py", line 216, in doRequest
    response = opener.open(req, body, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1346, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.6/urllib/request.py", line 1320, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 111] Connection refused>
2019-01-30 22:22:06,448 ERROR Error running python updateBuffer()
Traceback (most recent call last):
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/usr/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

...

Additional information: Output of OmniSharp.exe -v. Fails to load some dlls, doesn't seem fatal though.

info: OmniSharp.Http.Startup[0]
      Starting OmniSharp on Windows 6.2.9200.0 (x64)
info: OmniSharp.Cake.CakeProjectSystem[0]
      Detecting Cake files in 'C:\tools\Omnisharp\omnisharp'.
info: OmniSharp.Cake.CakeProjectSystem[0]
      Could not find any Cake files
info: OmniSharp.Http.Startup[0]
      Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
dbug: OmniSharp.MSBuild.Discovery.MSBuildLocator[0]
      Attempting to resolve 'Microsoft.Build'
fail: OmniSharp.Services.AssemblyLoader[0]
      Failed to load assembly from path: C:\tools\Omnisharp\omnisharp\msbuild\15.0\Bin\Microsoft.Build.dll
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\tools\Omnisharp\omnisharp\msbuild\15.0\Bin\Microsoft.Build.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
File name: 'file:///C:\tools\Omnisharp\omnisharp\msbuild\15.0\Bin\Microsoft.Build.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at OmniSharp.Services.AssemblyLoader.LoadFrom(String assemblyPath, Boolean dontLockAssemblyOnDisk)


fail: OmniSharp.Http.Startup[0]
      The project system 'OmniSharp.MSBuild.ProjectSystem' threw exception during initialization.
System.TypeInitializationException: The type initializer for 'OmniSharp.MSBuild.MSBuildHelpers' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Build' or one of its dependencies. The system cannot find the file specified.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.Assembly.Load(AssemblyName assemblyRef)
   at OmniSharp.MSBuild.MSBuildHelpers..cctor()
   --- End of inner exception stack trace ---
   at OmniSharp.MSBuild.MSBuildHelpers.GetBuildEnvironmentInfo()
   at OmniSharp.MSBuild.ProjectSystem.Initalize(IConfiguration configuration)
   at OmniSharp.WorkspaceInitializer.Initialize(IServiceProvider serviceProvider, CompositionHost compositionHost, IConfiguration configuration, ILogger logger)
info: OmniSharp.Script.ScriptProjectSystem[0]
      Detecting CSX files in 'C:\tools\Omnisharp\omnisharp'.
info: OmniSharp.Script.ScriptProjectSystem[0]
      Could not find any CSX files
info: OmniSharp.Http.Startup[0]
      Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
info: OmniSharp.Http.Startup[0]
      Configuration finished.
info: OmniSharp.Http.Startup[0]
      Omnisharp server running on port '2000' at location 'C:\tools\Omnisharp\omnisharp' on host -1.

Output for ~/.omnisharp/omnisharp-roslyn/run -v is similar, no errors though. The dlls load successfully.

I've looked through all the past issues and can't figure out for the life of me what's wrong. I think I'm cursed.

@kuator
Copy link

kuator commented Jan 31, 2019

Same stuff on my machine: Linux mint 19,

❯ dotnet --version                             
2.2.103
❯ nvim --version 
NVIM v0.3.1
❯ cat /etc/lsb-release 
DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=19
DISTRIB_CODENAME=tara
DISTRIB_DESCRIPTION="Linux Mint 19 Tara"
2019-01-31 21:43:37,283 ERROR Could not connect to OmniSharp server: http://localhost:39583/checkalivestatus
Traceback (most recent call last):
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1285, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1234, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1026, in _send_output
    self.send(msg)
  File "/usr/lib/python3.6/http/client.py", line 964, in send
    self.connect()
  File "/usr/lib/python3.6/http/client.py", line 936, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.6/socket.py", line 724, in create_connection
    raise err
  File "/usr/lib/python3.6/socket.py", line 713, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused


@nickspoons
Copy link
Member

@Mantissa-23 on WSL with let g:OmniSharp_translate_cygwin_wsl = 1, you can use the latest releases of OmniSharp-roslyn - you don't need to stay on 1.32.1. However, vim/nvim can't install the windows version automatically, so you'll need to either do that manually, or open a Windows vim/nvim and do the :OmniSharpInstall from there, which is what I do. I find a Windows gVim is the easiest, but you can probably also do it with a Windows terminal vim/nvim if you can get one working, or nvim-qt - I've never tried those options though.

When you manually install the server, are you getting the http-win-x64 version?

Am I correct in assuming that you are running .NET framework projects, hosted in Windows? If you are doing dotnet core stuff, you can keep it all in the WSL layer which is simpler - to do that, drop the let g:OmniSharp_translate_cygwin_wsl = 1 line from your init.vim.

@nickspoons
Copy link
Member

@abylkasymovkuat you are describing a completely different environment, I suspect your problem is unrelated to this issue. Try running ~/.omnisharp/omnisharp-roslyn/run -v from the folder containing your .sln file and see if the server is starting correctly. If it is, and you are still having problems, please open a new issue, containing the output of the above command.

@kuator
Copy link

kuator commented Feb 1, 2019

@nickspoons, after sitting several hours trying to get it to work, it eventually started to. Though, when the
server starts, and when I use intellisense, the fans are getting crazy.

@nickspoons
Copy link
Member

@abylkasymovkuat:

https://xkcd.com/979/

@vdmarques
Copy link

vdmarques commented Feb 17, 2019

@kuator Pls tellme what you do to fix ?? Im trying to use neovim but i go back to vscode because omnisharp dont work...

@nickspoons
Copy link
Member

This is an OmniSharp-roslyn issue - possibly similar to OmniSharp/omnisharp-roslyn#1400 and OmniSharp/omnisharp-roslyn#1416

There has been a lot of work done in OmniSharp-roslyn since version 1.32.1 so I suggest updating to a later version.

Closing.

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

4 participants