Kodi Community Forum
Access Outside my Home Network - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: General Support (https://forum.kodi.tv/forumdisplay.php?fid=111)
+---- Forum: OS independent / Other (https://forum.kodi.tv/forumdisplay.php?fid=228)
+---- Thread: Access Outside my Home Network (/showthread.php?tid=89084)

Pages: 1 2


Access Outside my Home Network - swholden - 2010-12-31

First I'd like to say this is pretty great stuff here!
Great job to those who've put all the work into this.

I actually have 2 questions, and I apologize if it's been answered already, but I've been searching and can't seem to find what I am looking for.

1) I'd like to access my library from outside my home. (i.e. work, on the road, where ever).
I thought I had it configured correctly but when accessing via a browser, the it just seems to search for movies.
When using XBMC (my prefer method 'cause it looks so cool) I get an error of:
Remote Share Can not connect to network server.

2) Any chance there's a Roku Channel in the works to connect to the XBMC Media Server? I know there are other methods, but just a thought.

#1 is the most important now. If some one could point me in the correct direction, that would be great.

Thanks in advance, and great job!


- czfj5r - 2010-12-31

This thread sounds great if it is possible through XBMC...

Just as info I have used LogMeIn (logmein.com) for a number of solutions incl VPN... Free for non-commercial..
Not sure if that is what you might be looking for.

Accessing media library otherwise is posible through ORB (orb.com I think). Not using it myself but stumbled across it when arriving at XBMC...

Just as info as stated... Smile


- Gryph - 2010-12-31

Well a little extra input is probably needed; what OS etc.

I'm using Ubuntu 10.10 x64 cut down minimal version; with Samba you can allow the file shares to show externally, and if you're using MySQL for your database then I don't see any problems with being able to access the files and library remotely.
Just setup your advancesettings.xml to point to the external IP for your MySQL server.

Of course, leaving your samba open to public can be disastrous; unless you've set up security for it, but I still wouldn't go leaving samba open externally.

Whereas I want a bit more security, I have an OpenVPN access server, I connect and even externally I'm in routed through my internal network and can view it that way.
If you want to go down the OpenVPN path, they have the access server for most OS, and free (so long as you only want to have 2 consecutive connections)


- swholden - 2010-12-31

I use logmein, but for other things. The free vrsion doesn't play sound I think. Could be wrong.....I just log into the various machines I maintain, do my thing and get out.

XBMC appears that you can do this (stream outside the local network), just trying to figure out how.

I managed to access the video files using a browser, but..... am I mistaken, that only controls the server and plays the video locally? At least that's what happens to me. Smile

Thanks for your reply.


- swholden - 2010-12-31

@Gryph. Sorry, didn't see your reply before I answered previously.

I'm running windows 7. I primarily want to use it as a media server streaming to various devices in the house, but want access while on the road.

XBMC seemed to allow that. Else why configure the network setting with a port, user and password?

What you say seems a bit "over the top" (so to speak). It's not extremely necessary, since I can always put the videos on a portable drive, but it would be awesome if you could use xbmc to connect remotely and just play through that.

Maybe I'm getting myself confused. Smile


- Gryph - 2010-12-31

The "webserver" is used for a remote interface, which you can either invoke your content to play locally via that interface (or issue direct HTTP commands), what it doesn't do is play your media (whether internally or externally)

So either you need to access your shares (and library) externally, or use a VPN client to route to your internal network.

Of course, you'd need another copy of XBMC running on the machine you take externally with you and point the settings of your server.

You're main step would be to setup the database using MySQL (so that you can share off the same database information), there are other steps included as well to share the same thumbnails. Setting up MySQL & the shared thumbnails are detailed in the forums (sorry, don't have direct links for you)

Not sure exactly how you can share your content externally via Windows, but again, you'd want more security doing this.

Hope this information helps you out.


- swholden - 2010-12-31

I have another copy of XBMC running on another computer, which my plan was to access the media through that. Pointing at the IP which has been forward to that particular machine.

So what you're saying is it can't be done using XBMC solely?

Hmmmm......seems so simple. Why wouldn't one want to do that?

The settings provide some sort of security.....


- Gryph - 2010-12-31

Again, the user/pass port is only for a web remote interface. I'm sure if you were to develop a method of streaming over the http protocol and submit it via trac then the developers could look at the feasibility of it.

But if you want to setup your main machine using MySQL for the database, and share the thumbs directory, this is another scenario.

On another PC have XBMC running, then setup the advancedsettings.xml file with your MySQL database details of your main machine, and point the folder shares to the location on your main machine.

Then you have a full running copy of XBMC using the database of the main PC.

Externally, you can leave those EXACT settings, and say if you're running a VPN server, you can just "dial" into your server, pickup you internal address ranges, and bang ... you're back on ... Minimum Time ... Maximum Fear!


- czfj5r - 2010-12-31

swholden,

Logmein is, as you say a way to remote connect but with Hamachi (I think) you can setup a secure network.

In regards to the webinterface to XBMC Gryph is right, it is to remotley manage the XBMC.
I have a remote control on the iPOD touch so as example I pause and stop the XBMC instance for the kids when it is time to eat. I can then log in to the other instance and start the music for the dinner session (as I have 5 XBMC instances across the house). It is very neat and an easy way to manage it all ("one to rule them all" Smile )

If you wnat access outside check teh MySQL solution + VPN. Either teh LogMeIn type opr the OpenVPN that Gryph suggests.


- swholden - 2010-12-31

Thank you both to your replies.

Sounds like the MySql solution is what I need to do, as developing my own method of streaming is truly beyond my capabilities. And my wife kept telling me years ago to go back to school and learn to write code. Smile

Are there any cut and dry instructions on setting something like this up?
Or and I'm I on my own?

I see Mysql is free to downoad as are some VPN clients, but I'm not sure what to download and where. (ie. Do I install the same VPN in each machine, or server on one?)

Any suggestions that can point me in the right direction would be great.

THanks again!


Instructions - czfj5r - 2010-12-31

On VPn I do not really know. Check out the Logmein site on how to set this up or search teh forums.

On MySQL there are threads if you search but below is an explanation I used and stored away. I hope it can help. I run MySQL on a Windows Home server and it runs superb... Smile

....

Configuring XBMC to use a MySQL library
The release of XBMC Dharma has introduced a very cool new feature: the ability to use a MySQL database. Whereas it has been possible to share content over network shares, the library was always stored locally in the built-in SQLite database. Dharma adds the option to use MySQL which can be hosted on the same machine as the XBMC instance or on a remote system on the network. This article explains how to install MySQL and configure both it and XBMC to use this capability.
It assumes a fair level of familiarity with XBMC, with editing XML files, and installing software. It does not assume you’re an expert either in the MySQL product or in SQL but some basic knowledge here would certainly be useful – for a great tutorial on SQL see webdevelopersnotes.com. I also assume that a high level of security on the LAN is not required so the xbmc system will have full access to the MySQL databases.
My scenario
The PCs and servers being used for this upgrade are as follows:
MACMINI: 3rd generation Apple MacMini hardware running Windows 7 with XBMC Dharma beta 3. Content is accessed from network shared volumes mapped to drive letters, local SQLite database, Thumbnails on a network share volume. IP address 192.168.1.64/24.
RACK: Server running MySQL on Windows 7, directly connected to 2x DroboPros with the content, sharing content to the LAN over 5x SMB shares. Runs an Intel Atom processor with 2Gb RAM, 128Gb SSD, 4x GigE network ports and Windows 7. IP address on the LAN is 192.168.1.16/24, the DroboPros are each connected directly to one of the other LAN ports for maximum performance.
In my setup the MySQL database will be installed on RACK with XBMC and the MySQL Workbench running on MACMINI.
Installation in 7 steps
1. Install MySQL and verify that it works using MySQL Workbench
2. Manually configure MySQL to prepare it for XBMC
3. Configure XBMC to use MySQL rather than SQLite
4. Start XBMC and verify that the tables have been correctly configured
5. Edit the paths to the sources to use SMB shares and not local references
6. Scan the sources to populate the library on MySQL
7. Optimise the MySQL installation
Step 1. Install MySQL and verify that it works using MySQL Workbench
Full tutorials on how to install MySQL for your platform can be found elsewhere but the short answer is to download MySQL Community Edition and the MySQL Workbench (GUI Tool) from the MySQL downloads page and install with the defaults.
You can install the MySQL Workbench on the same system as the MySQL database or on a different system, no issue either way. Personally I prefer different systems as this more closely mimics how the XBMC machines will communicate with the server – over the LAN and not through a loopback (localhost or 127.0.0.1).
When they’re all installed launch MySQL Workbench and create a New Connection under the SQL Development section. This will prompt you for a name for the connection (‘root on RACK’ in my case), the IP address of the server (192.168.1.16), port (default 3306), username (default root) and password (as entered during the installation process for the MySQL database). You can then open the connection to start querying the MySQL server instance; if it doesn’t connect then you’ve probably got an issue with the setup or perhaps your firewalling.
Step 2: Manually configure MySQL for XBMC
Assuming the MySQL and the MySQL Workbench are running, our first step is to create a user that will access the two databases we’ll be setting up. Use the SQL Editor in MySQL Workbench to send commands to and view responses from the MySQL server. Here the username (USER) will be xbmc and the password (IDENTIFIED BY) will also be xbmc.
CREATE USER 'xbmc' IDENTIFIED BY 'xbmc';
Note: If you get an error 1396 when trying this then you’ve probably hit a bug; you’ll have to DROP the user manually in MySQL Workbench before re-creating them.
Next we have to create two empty databases which XBMC will populate with tables and columns the first time it starts and successfully access the MySQL server:
CREATE DATABASE xbmc_video CHARACTER SET latin1 COLLATE latin1_general_ci;
CREATE DATABASE xbmc_music CHARACTER SET latin1 COLLATE latin1_general_ci;
Lastly, we need to give the user ‘xbmc’ access to the databases:
GRANT ALL ON *.* to 'xbmc'
Step 3: Configure XBMC to use MySQL rather than SQLite
If it’s still running, quit XBMC. Open the advancedsettings.xml file from the userdata folder in a text editor like Notepad. Add the following lines at the end, above the </advancedsettings>:
<videodatabase>
<type>mysql</type>
<host>192.168.1.16</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_video</name>
</videodatabase>

<musicdatabase>
<type>mysql</type>
<host>192.168.1.16</host>
<port>3306</port>
<user>xbmc</user>
<pass>xbmc</pass>
<name>xbmc_music</name>
</musicdatabase>
Where <host> is the name or explicit IP address of the MySQL server (I have RACK mapped to 192.168.1.16 in my hosts file, so I could have used the name RACK in place of the IP address), and <user> and <pass> are the username and password specified in step 2.
Step 4: Start XBMC and verify that the tables have been correctly configured
When you start XBMC after completing step 3 XBMC will connect to the MySQL server, find the empty databases and populate them with all the correct tables and columns. As soon as XBMC displays the menu from the skin this will have been completed. To verify that it has worked as expected open the xbmc.log file and check to make sure there are no ‘ERROR: SQL: …’ messages. Assuming none, then use MySQL Workbench to check the databases and see that all the tables are there.
Step 5: Edit the paths to the sources to use SMB shares and not local references
I’m sure you don’t want to have to add all your content to the new MySQL-based library through a re-scan or library update as this could take a long time due to re-scraping. For sure the faster approach would be to export the library from within XBMC when still using the SQLite database, switch to MySQL as explained above, then re-import.
Now, this approach does work if your content is already stored on network shares and referenced by the UNC path in XBMC: e.g., as smb://RACK/480p movies/ and not to a drive letter S:\480p movies\. But most people don’t have this, their existing libraries map to local drive letters.
OK you say, so I won’t change to SMB network paths, I’ll just map those shares to the same drive letters that I was accessing locally. So S: that was attached locally becomes S: that now maps to the share. Good idea. But it doesn’t work. The reason is that the backslash character is reserved in MySQL so when you try and import the library you’ll get an error ‘ERROR: SQL: Undefined MySQL error: Code (1062)‘ and the database won’t be updated. UNC paths use forward slashes so they work fine.
As the sources I was using in XBMC pointed to locally-mapped network drives (e.g. S: pointed to \\RACK\480p movies\) I need to edit each and every one of my sources to pull data from a SMB reference as opposed to a local drive reference. That means selecting ‘Videos’ from the XBMC menu, turning off library mode, then editing each source to change the location.
Step 6: Scan the sources to populate the library on MySQL
With all the sources now referencing SMB network paths I can re-scan and XBMC will find the ‘new’ content, scrape the metadata as needed from IMDb, thetvdb.com etc. and update the library on MySQL. If you use a SQL Editor window in MySQL Workbench you can run queries as it’s happening to see the new rows:
SELECT * from xbmc_video.movie;
This will display all the movies that XBMC has found. If you just want to see how many rows (separate movies) XBMC has in the MySQL database then use:
SELECT COUNT(*) from xbmc_video.movie;
In the above queries replace ‘movie‘ with ‘tvshow‘ and instead you’ll see all the TV shows.
Step 7: Optimise the MySQL installation
Certainly MySQL can be tuned for better performance. If you want to do that then the MySQL Performance Blog would be a good place to start.
But aside from that, what we’ve found is that the xbmc_video database is fine, but the xbmc_music database performs slowly as defined by XBMC. To improve this we can add three indices to the database which improve things dramatically:
ALTER TABLE xbmc_music.song ADD INDEX idx_idArtist(idArtist);
ALTER TABLE xbmc_music.song ADD INDEX idx_idGenre(idGenre);
ALTER TABLE xbmc_music.song ADD INDEX idx_idAlbum(idAlbum);
Delay of 3 minutes when you click on an Artist in Library mode.
Fixed by adding index: CREATE INDEX test_idx ON song(idAlbum);


Step 2 - czfj5r - 2010-12-31

Symlinks
As in the pros and cons at present posters are not able to be tracked or stored by the database. This means only the htpc which originally updates the library will shows the correct images for items in the library. At present to get the images you will need to refresh each item or enter and exit the info screen for each item.

Use symlinks (Vista and Win 7) to share thumbnails folder. Using symlinks all thumbnails are held on one pc (usually the same as the mysql db sits on) and rather than a folder a shortcut is essentially created which points each other pc to the shared folder.
Pros:
- Only one copy of each file is created.
- All systems always show correct images

Cons:
- Network performance will control how quickly images can be loaded so can impact user experience.
What I did (in Windows) was to go to the UserData folder and delete the "thumbnails" folder (you can make a copy of it to your shared folder in the central location first if you want, otherwise the thumbnails should just recreate).
You should have a shared location that the account running XBMC can access and write to from each of your XBMC installations.
from the command prompt (no way to do this in GUI) do "mklink /d Thumbnails \\server\share"
It will create what looks like a folder called "thumbnails" but it will actually be a link to the shared folder. It'll have a different folder icon in Windows. It should stay after each reboot.

Scheduled Backup of MySQL
I have used this little trick to do backup of the database. Perhaps it can help. Windows related though...
1. Open Notepad
2. Add the following to the file:
"C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump.exe" --user=xbmc --password=xbmc --add-drop-table --all-databases --result-file=C:\Temp\backup-%DATE%.sql --dump-date
3. Save the file with a .cmd at the end, as example "MySQLBackup.cmd"
4. Go to control panel / schedule task / add new task

5. When asked for the program to run, browse to your newly created file and choose it. Then continue the wizard and choose the options you want (daily, weekly, ...)
Done.

In the commandtext above you need to be aware of the following:
- adjust the path to the mysqldump.exe if needed
- Insert your user and password (I used xbmc as example above)
- I have a %DATE% in the filename above, please be aware that if you use "/" as date seperator it will not work as that is not allowed in teh filename so change your regional settings to use "-" as date seperator
- after the --result-file= you can add the place you want the backup to be put (as example onto another share, usb-stick or...)

I also saw you wanted to remove things automatically after some time. I found the following command line item you can try to add to the file. I have NOT tested it but feel free
forfiles /p C:\Temp\ /m backup-*.* /d -7 /c "cmd /c del @path"
This command should remove files older than 7 days so just change the 7 to whatever you need. As said, not tested yet...
Hope it helps. You also do not have to add any other program as mysqldump comes with the MySQL installation


Link to thread as well - czfj5r - 2010-12-31

http://forum.xbmc.org/showthread.php?tid=85654


- swholden - 2010-12-31

Wow!
There some great reading here.
Guess I know what I'll be doing today and this weekend.

THanks all for the suggestions.....I'll let you know how I make out.

Again, kudos to the XBMC folks. This really is a great product.


- Gryph - 2011-01-01

As for OpenVPN, you can download the access server from: http://openvpn.net/
Setting up can be a little tricky, as you need to know a little about networks to be able to route to your internal IP range.

But once up and running you can log into the webinterface of the access server and download the client (with your relevant security details included).

Simply download that on any machine that you take away with you and then just "dial" into your server using the client and you're routed back into your internal network.