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

"CONNECTION: ''" Error on CentOS while the omnisharp server is successfully running #410

Closed
AlseinX opened this issue Sep 16, 2018 · 7 comments

Comments

@AlseinX
Copy link

AlseinX commented Sep 16, 2018

neofetch:

OS: CentOS Linux 7 (Core) x86_64
Host: Bochs
Kernel: 3.10.0-514.26.2.el7.x86_64
Uptime: 81 days, 1 hour, 28 mins
Packages: 670 (rpm)
Shell: zsh 5.0.2
Terminal: /dev/pts/1
CPU: Intel Xeon E5-26xx v4 (1) @ 2.399GH
GPU: Cirrus Logic GD 5446
Memory: 223MiB / 1839MiB

vim version:

root@VM_0_2_centos ~/CoreProjects/CoreTest1/src/CoreTest1$ vim --version                                                                                                                                         
VIM - Vi IMproved 8.1 (2018 May 18, compiled Sep 17 2018 01:06:46)
Included patches: 1-398
Compiled by root@VM_0_2_centos
Huge version without GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            +farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +timers
+byte_offset       -hangul_input      +num64             +title
+channel           +iconv             +packages          -toolbar
+cindent           +insert_expand     +path_extra        +user_commands
-clientserver      +job               -perl              +vartabs
-clipboard         +jumplist          +persistent_undo   +vertsplit
+cmdline_compl     +keymap            +postscript        +virtualedit
+cmdline_hist      +lambda            +printer           +visual
+cmdline_info      +langmap           +profile           +visualextra
+comments          +libcall           +python            +viminfo
+conceal           +linebreak         -python3           +vreplace
+cryptv            +lispindent        +quickfix          +wildignore
+cscope            +listcmds          +reltime           +wildmenu
+cursorbind        +localmap          +rightleft         +windows
+cursorshape       -lua               -ruby              +writebackup
+dialog_con        +menu              +scrollbind        -X11
+diff              +mksession         +signs             -xfontset
+digraphs          +modify_fname      +smartindent       -xim
-dnd               +mouse             +startuptime       -xpm
-ebcdic            -mouseshape        +statusline        -xsmp
+emacs_tags        +mouse_dec         -sun_workshop      -xterm_clipboard
+eval              -mouse_gpm         +syntax            -xterm_save
+ex_extra          -mouse_jsbterm     +tag_binary        
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: gcc -std=gnu99 -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc -std=gnu99   -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lnsl   -ldl    -L/usr/lib64/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic

.vimrc:

let g:OmniSharp_server_use_mono = 1

" OmniSharp won't work without this setting
filetype plugin on

" Set the type lookup function to use the preview window instead of echoing it
"let g:OmniSharp_typeLookupInPreview = 1

" Timeout in seconds to wait for a response from the server
let g:OmniSharp_timeout = 5

" Don't autoselect first omnicomplete option, show options even if there is only
" one (so the preview documentation is accessible). Remove 'preview' if you
" don't want to see any documentation whatsoever.
set completeopt=longest,menuone,preview

" Fetch full documentation during omnicomplete requests.
" There is a performance penalty with this (especially on Mono).
" By default, only Type/Method signatures are fetched. Full documentation can
" still be fetched when you need it with the :OmniSharpDocumentation command.
"let g:omnicomplete_fetch_full_documentation = 1

" Set desired preview window height for viewing documentation.
" You might also want to look at the echodoc plugin.
set previewheight=5

" Tell ALE to use OmniSharp for linting C# files, and no other linters.
let g:ale_linters = { 'cs': ['OmniSharp'] }

augroup omnisharp_commands
    autocmd!

    " When Syntastic is available but not ALE, automatic syntax check on events
    " (TextChanged requires Vim 7.4)
    " autocmd BufEnter,TextChanged,InsertLeave *.cs SyntasticCheck

    " Show type information automatically when the cursor stops moving
    autocmd CursorHold *.cs call OmniSharp#TypeLookupWithoutDocumentation()

    " The following commands are contextual, based on the cursor position.
    autocmd FileType cs nnoremap <buffer> gd :OmniSharpGotoDefinition<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>fi :OmniSharpFindImplementations<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>fs :OmniSharpFindSymbol<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>fu :OmniSharpFindUsages<CR>

    " Finds members in the current buffer
    autocmd FileType cs nnoremap <buffer> <Leader>fm :OmniSharpFindMembers<CR>

    autocmd FileType cs nnoremap <buffer> <Leader>fx :OmniSharpFixUsings<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>tt :OmniSharpTypeLookup<CR>
    autocmd FileType cs nnoremap <buffer> <Leader>dc :OmniSharpDocumentation<CR>
    autocmd FileType cs nnoremap <buffer> <C-\> :OmniSharpSignatureHelp<CR>
    autocmd FileType cs inoremap <buffer> <C-\> <C-o>:OmniSharpSignatureHelp<CR>


    " Navigate up and down by method/property/field
    autocmd FileType cs nnoremap <buffer> <C-k> :OmniSharpNavigateUp<CR>
    autocmd FileType cs nnoremap <buffer> <C-j> :OmniSharpNavigateDown<CR>
augroup END

" Contextual code actions (uses fzf, CtrlP or unite.vim when available)
nnoremap <Leader><Space> :OmniSharpGetCodeActions<CR>
" Run code actions with text selected in visual mode to extract method
xnoremap <Leader><Space> :call OmniSharp#GetCodeActions('visual')<CR>

" Rename with dialog
nnoremap <Leader>nm :OmniSharpRename<CR>
nnoremap <F2> :OmniSharpRename<CR>
" Rename without dialog - with cursor on the symbol to rename: `:Rename newname`
command! -nargs=1 Rename :call OmniSharp#RenameTo("<args>")

nnoremap <Leader>cf :OmniSharpCodeFormat<CR>

" Start the omnisharp server for the current solution
nnoremap <Leader>ss :OmniSharpStartServer<CR>
nnoremap <Leader>sp :OmniSharpStopServer<CR>

" Add syntax highlighting for types and interfaces
nnoremap <Leader>th :OmniSharpHighlightTypes<CR>

" Enable snippet completion
let g:OmniSharp_want_snippet=1

call plug#begin('~/.vim/plugged')

Plug 'OmniSharp/omnisharp-vim'
Plug 'SirVer/ultisnips'
Plug 'w0rp/ale'

call plug#end()

the folder structure which was briefly made by dotnet commands:

├── CoreTest1.sln
└── src
    └── CoreTest1
        ├── CoreTest1.csproj
        └── Program.cs

building succesfully:

root@VM_0_2_centos ~/CoreProjects/CoreTest1$ dotnet build                                                                                                      
Microsoft (R) Build Engine version 15.8.166+gd4e8d81a88 for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 58.08 ms for /root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj.
  CoreTest1 -> /root/CoreProjects/CoreTest1/src/CoreTest1/bin/Debug/netcoreapp2.1/CoreTest1.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:01.71

result of manually running the omnisharp server:

root@VM_0_2_centos ~/CoreProjects/CoreTest1/src/CoreTest1$ mono /root/.omnisharp/omnisharp-roslyn/OmniSharp.exe -p 60410 -s /root/CoreProjects/CoreTest1/CoreTest1.sln                                           
info: OmniSharp.Http.Startup[0]
      Starting OmniSharp on centos 7.0 (x64)
info: OmniSharp.Cake.CakeProjectSystem[0]
      Detecting Cake files in '/root/CoreProjects/CoreTest1'.
info: OmniSharp.Cake.CakeProjectSystem[0]
      Could not find any Cake files
info: OmniSharp.WorkspaceInitializer[0]
      Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
info: OmniSharp.MSBuild.ProjectSystem[0]
      Detecting projects in '/root/CoreProjects/CoreTest1/CoreTest1.sln'.
info: OmniSharp.MSBuild.ProjectManager[0]
      Queue project update for '/root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj'
info: OmniSharp.Script.ScriptProjectSystem[0]
      Detecting CSX files in '/root/CoreProjects/CoreTest1'.
info: OmniSharp.Script.ScriptProjectSystem[0]
      Could not find any CSX files
info: OmniSharp.WorkspaceInitializer[0]
      Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
info: OmniSharp.WorkspaceInitializer[0]
      Configuration finished.
info: OmniSharp.Http.Startup[0]
      Omnisharp server running on port '60410' at location '/root/CoreProjects/CoreTest1' on host -1.
info: OmniSharp.MSBuild.ProjectManager[0]
      Loading project: /root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj
info: OmniSharp.MSBuild.ProjectManager[0]
      Successfully loaded project file '/root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj'.
info: OmniSharp.MSBuild.ProjectManager[0]
      Adding project '/root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj'
info: OmniSharp.MSBuild.ProjectManager[0]
      Update project: CoreTest1

there seems not to be a problem. C-c exited.

vim Program.cs entering vim, and nothing was changed, like omnisharp-vim was never installed.

making sure server was automatically started by the plugin:
:!ps -ef | grep omnisharp

root     24387 24384  3 04:20 ?        00:00:04 mono /root/.omnisharp/omnisharp-roslyn/OmniSharp.exe -p 36234 -s /root/CoreProjects/CoreTest1/CoreTest1.sln
root     24521 24384  0 04:23 pts/0    00:00:00 /bin/zsh -c ps -ef | grep omnisharp

running :OmniSharpCodeFormat and got this screen with red error texts "CONNECTION: ''":

using System;

namespace CoreTest1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }
}
~
~
~
~
~
~
~
~
~
~
~
CONNECTION: ''
@nickspoons
Copy link
Member

Hi there,

There's an issue with the latest releases of omnisharp-roslyn not accepting Http connections. Please try the latest working version, by running this from the vim command line:

:OmniSharpInstall 'v1.32.1'

If you still have problems (hopefully not), try removing your set g:OmniSharp_server_use_mono = 1 line and then running the above OmniSharpInstall again. You generally don't need it on Linux (although I haven't tried CentOS to be sure) but it controls which omnisharp-roslyn to download as well as how it's executed, so if you change the setting you need to install the new server too.

nickspoons added a commit that referenced this issue Sep 16, 2018
Until OmniSharp/omnisharp-roslyn#1274 is
resolved, `:OmniSharpInstall` with no arguments will install version
v1.32.1

Closes #393, #410
@nickspoons
Copy link
Member

@AlseinX I've just made a change so the default :OmniSharpInstall installs OmniSharp-Roslyn v1.32.1, so you can still run the above command, or just

:OmniSharpInstall

If this doesn't solve your problem, please re-open this issue.

@AlseinX
Copy link
Author

AlseinX commented Sep 16, 2018

running :OmniSharpInstall 'v1.32.1' there are even more problems, the omnisharp server stops working.

root@VM_0_2_centos ~/CoreProjects/CoreTest1/src/CoreTest1$ mono /root/.omnisharp/omnisharp-roslyn/OmniSharp.exe -p 60410 -s /root/CoreProjects/CoreTest1/CoreTest1.sln
info: OmniSharp.Http.Startup[0]
      Starting OmniSharp on centos 7.0 (x64)
info: OmniSharp.Cake.CakeProjectSystem[0]
      Detecting Cake files in '/root/CoreProjects/CoreTest1'.
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.
info: OmniSharp.MSBuild.ProjectSystem[0]
      Detecting projects in '/root/CoreProjects/CoreTest1/CoreTest1.sln'.
info: OmniSharp.MSBuild.ProjectManager[0]
      Queue project update for '/root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj'
info: OmniSharp.Script.ScriptProjectSystem[0]
      Detecting CSX files in '/root/CoreProjects/CoreTest1'.
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 '60410' at location '/root/CoreProjects/CoreTest1' on host -1.
info: OmniSharp.MSBuild.ProjectManager[0]
      Loading project: /root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj
System.AggregateException: One or more errors occurred. (libuv) ---> System.DllNotFoundException: libuv
  at (wrapper managed-to-native) Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv+NativeMethods.uv_loop_size()
  at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.loop_size () [0x00000] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
  at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle.Init (Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv uv) [0x0000c] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
  at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.ThreadStart (System.Object parameter) [0x00029] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
   --- End of inner exception stack trace ---
  at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011] in <dac57913d8d54bde9ace4c332c44c2f5>:0 
  at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System.Threading.CancellationToken cancellationToken) [0x00043] in <dac57913d8d54bde9ace4c332c44c2f5>:0 
  at System.Threading.Tasks.Task.Wait () [0x00000] in <dac57913d8d54bde9ace4c332c44c2f5>:0 
  at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.Start (System.Int32 count) [0x00037] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
  at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext] (Microsoft.AspNetCore.Hosting.Server.IHttpApplication`1[TContext] application) [0x0044b] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
  at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start () [0x00053] in <24af31b64ae843689736582353a19b3a>:0 
  at OmniSharp.Http.Host.Start () [0x000ab] in <8959a21458834a128afcd6caf0ea47d5>:0 
  at OmniSharp.Http.Driver.Program+<>c__DisplayClass0_1.<Main>b__1 () [0x0004f] in <689cc1cd84ed4fa1ba7232b3270b50a7>:0 
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <3239e8b00e0a4ebd9dc65c215d41bd64>:0 
  at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x0035b] in <e56ebbc3ed87488b8e26736bbadaa5d3>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <3239e8b00e0a4ebd9dc65c215d41bd64>:0 
  at OmniSharp.Http.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <689cc1cd84ed4fa1ba7232b3270b50a7>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <3239e8b00e0a4ebd9dc65c215d41bd64>:0 
---> (Inner Exception #0) System.DllNotFoundException: libuv
  at (wrapper managed-to-native) Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv+NativeMethods.uv_loop_size()
  at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.loop_size () [0x00000] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
  at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle.Init (Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv uv) [0x0000c] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 
  at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.ThreadStart (System.Object parameter) [0x00029] in <43555eec0dc34d2abb4f01227fa5a2e9>:0 <---

warn: OmniSharp.MSBuild.ProjectManager[0]
      Failed to load project file '/root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj'.

I triple checked I do have libuv installed.
BTW I can't remove let g:OmniSharp_server_use_mono = 1 because the runtime included in omnisharp server itself seems too old to support a .NET Core 2.1 projects. Having this line and upgrading the mono version to Nightly channel was the only way that I could make the omnisharp server work with no warns or errors.

@nickspoons
Copy link
Member

OmniSharp-roslyn has no problems for with the latest .NET core.

Did you try removing the g:OmniSharp_server_use_mono line and running :OmniSharpInstall ?

@nickspoons nickspoons reopened this Sep 17, 2018
@nickspoons
Copy link
Member

When testing the server from the commandline, try using the run script instead of explicitly calling OmniSharp.exe

@AlseinX
Copy link
Author

AlseinX commented Sep 17, 2018

If I remove this line, the omnisharp-vim calls run script to start the omnisharp server.
And run scripts always output

warn: OmniSharp.MSBuild.ProjectManager[0]
      Failed to load project file '/root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj'.
fail: OmniSharp.MSBuild.ProjectManager[0]
      Attemped to update project that is not loaded: /root/CoreProjects/CoreTest1/src/CoreTest1/CoreTest1.csproj

@AlseinX
Copy link
Author

AlseinX commented Sep 17, 2018

Luckily I tried installing libuv-devel as well and v1.32.1 eventually works.

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

2 participants