1

After the long battle, I've finally hosted my web API on Raspberry Pi 3b with Ubuntu 16.04 (Ubuntu Mate) OS but with lots of workarounds. One of which bothers me a lot and is about the connection string.

Setup:

  • Web Api hosted on RPi
  • Web Api is using EntityFrameworkCore SQL Server
  • SQL Server Express DB server on Windows 10
  • netcoreapp2 published for ubuntu.16.04-arm on Windows

Original connection string that works on Windows but not on Ubuntu:

"Server=MyHostName\\SQLEXPRESS,1433;Database=MyDb;User Id=sa;Password=MyPassword;"

Connection string that works on Ubuntu

"Server=192.168.254.150;Database=MyDb;User Id=sa;Password=MyPassword;"

Is there any way that I can make this work without relying on my Windows' IP address?

I understand these are fairly new releases so I've somehow settled on setting a static IP address crossing my fingers for it to not cause problems on the foreseeable future.

Lawrence
  • 334
  • 2
  • 12
  • You could add an `lmhosts` file, which will map the `netbios name` to the `ip address`. But that's nothing more than putting the static `ip address` into the connection string. On the other hand it's a central location for the mapping. See ubuntu manual for setting up the `lmhosts` file. http://manpages.ubuntu.com/manpages/xenial/man5/lmhosts.5.html – SS_DBA Apr 27 '17 at 13:43
  • Unfortunately, I'm betting this will require the same effort (if not more) for me to just change the `appsettings.json` once my IP address changed. Thanks for the idea though! – Lawrence Apr 27 '17 at 13:53
  • I don't think this is directly related to .NET Core, it's more to do with DNS and/or NetBIOS names configuration on Ubuntu. The underlying O/S will try to resolve the hostname you give into an IP address anyway, but if it's not configured to do that (as Ubuntu isn't, out of the box) then it can't. You'd have the same problem if you tried to access a fileshare on the Windows box, or RDP to it from Ubuntu. Usually it's easier if all the machines are part of a corporate domain with proper directory entries. On a home or other adhoc network it's a pain, but there are ways to make it use netBIOS. – ADyson Apr 27 '17 at 14:18
  • @ADyson I've actually tried to resolve that issue (currently I can only ping the windows server via IP address from Ubuntu) but got sidetracked when I saw similar cases for people using .netcore on docker. Currently, I'm still having ping issues even after `winbind` and `libnss-winbind` stuffs. Need to retire for the day and will continue tomorrow. **Some Context**: Yes, I'm on home network and don't have DSL connection (just LTE/Wireless) and only seeing limited configuration in the router to work with. – Lawrence Apr 27 '17 at 15:50

0 Answers0