I've researched this for a few hours now and I can't seem to find a solution.
I have a Rails 2 app that uses the TinyTds gem ( tiny_tds ) to connect to an SQL 2000 server hosted locally in our company.
The app has been connecting to SQL Server almost every day for the past 6 months with no problem.
Suddenly, when trying to connect yesterday, I started getting an error:
TinyTds::Error: Unable to open socket
from /var/lib/gems/1.8/gems/tiny_tds-0.4.5/lib/tiny_tds/client.rb:60:in `connect'
from /var/lib/gems/1.8/gems/tiny_tds-0.4.5/lib/tiny_tds/client.rb:60:in `initialize'
From my research, I've seen some people suggesting that I use
SO_REUSEADDR to allow it to connect and ignore timeout or "usage" restrictions, like this:
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR)
but I cannot figure out how to use that command within the current context.
I tried calling it in commmandline on the server and it won't work, but then again, I'm not sure what it does or if I can even call that from commandline.
I've tried calling
netstat -a
which shows current sockets, but I'm not sure what to do with that information.
I've also seen that
service restart
can restart a socket, but I'm not sure which socket to restart.
Lastly, in my freetds.conf configuration file, I have these settings:
host = 192.168.0.220
port = 1433
tds version = 8.0
I'm not really sure which road to take. I'm comfortable with Rails but this socket stuff is way outside my current understanding. This is also a Rails 2 app ( legacy ) which is key to some core processes our business uses. We can't upgrade to Rails 3 due to SQL server adapter gem for SQL 2000 Server won't work with Rails 3.
Can anyone help ?
Related
now I'm working on a Full-text search system, using web browser UI to find any text data file in my local network.
Here is develop environment.
OS:Macbook Air El Capitan 10.11.6
IDE:Cloud9
Lang:Ruby on Rails
SearchEngine:Elasticsearch
Using this site as a reference, I faced problems of PORT number many times.
(don't need to read sentence, since it's written in Japanese)
==========
I got this error many times importing db:seed, making index( _elasticsearch__.
create.~), ... and so on.
Faraday::ConnectionFailed: Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for "localhost" port 9200)
Also, I can't see anything in "localhost:9200" in my browser.
I had no setting about PORT number in cloud9, how should I do?
setting parameters in cloud9(cloud-network)
download this project from cloud9, and continue to make in local-network
which is better, or another better plan...
Follow the elastic search documentation
Installation
Download and unzip the Elasticsearch official distribution.
Run bin/elasticsearch on unix, or bin\elasticsearch.bat on windows.
Run curl -X GET http://localhost:9200/.
Start more servers …
I am using Aptana Studio 3 for development of ROR apps. I used run server command and it showed you can access your app on {http//0.0.0.0:3000/}, but when I try to access this URL, it tells me to check your Internet connection. I tried several other ports also but it is not working. I have created/modified the files necessary and migrated the database successfully too. Appreciate any help in running the app over the browser. I am currently using WeBrick Server.
so, in your title you say "on server". what does that mean? when you are running it on a different machine than your own, you need to use the address of that machine or it's domain name. keep in mind that firewall rules might prevent any connection to that server.
when you are ON the machine, via ssh for example, you can try calling the then "local" rails instance with curl http://localhost:3000/ to verify that it is running.
I'm experiencing what I believe is an environment issue, but I'm at my end as far as debugging it. I'm attempting to connect to a Sybase SqlAnywhere from a Rails 3.2.13 app on the same network. This is working from a rails 2.8 app, but I desperately need to upgrade.
It seems that I can connect through the rails console to the database the very first time that I create my new ruby gem and gemset using RVM, but subsequent attempts simply hang with no response after an attempt to query the database. I believe the database connection is being established as I get an error when incorrect credentials are supplied. After a successful connection on the first attempt, I am unable to replicate the success by opening a new terminal tab, setting the same gem and gemset, sourcing the database, and issuing the same query in the rails console.
I'm using a rails32 branch of a fork of the sqlanywhere adapter since the database adapter hasn't been supported by Sybase for a little while, but it has reported success using the same setup and I don't think this is the root of my issue since I've successfully returned valid data in the trials with limited success.
I've compared the working and non-working environments with no apparent difference, but is there anything significantly different about the RVM environment after the initialization of the gem/gemset that could be getting in the way?
I've installed the MySQL workbench version 5.2.34 and having problems creating a local connection. I'm getting an error saying "Can't Connect to MySQL Server on 127.0.0.1'(10061)" when i try connecting to Localhost on Port 3306. I tried restarting the service but i don't have the option to stop/start/pause or resume using Windows 7. The status is just set to "starting". I also tried "net stop mysql" from the command line in DOS but get the following error: "The service is starting or stopping. Please try again later"
Does anyone know if this is another bug in the Workbench or is there a quick solution to get around this?
You can restart mysql from services. Also, check error log (by default, on Windows 7 machine it's under ...ProgramData\MySQL\MySQL Server [version]\data
Sounds like a problem with MySQL itself starting up. You may have to kill the mysqld process if nothing else gets it into a started or stopped state, and then investigate the .err logs in your data directory.
This solution uses the window's mysql installer which you have used to install your MySQL.
Even though this post is very old, I have wasted around 2 hours and hence want to post this so that it can save someone else's time.
I have tried every other way of restartring the service, but mysql service just wont start.
Start your windows mysql installer. For me it was "mysql-installer-community-8.0.20.0"
Then remove/uninstall the SQL Server and remove all configurations
Manually delete the SQL Server folder from "C:\Program Files\MySQL\MySQL Server 8.0."
Start your mysql installer again and install the SQL Server again
You can check now that the MySqL Server has started.
Is it feasible to have a Ruby on Rails app, which is:
a) deployed on Heroku, and
b) working with a remote SQL Server database?
I take it that I'll need unixODBC installed on Heroku, but I cannot find a way to do so. Is this possible?
Or, is there any other way (without ODBC?) to accomplish this?
Thank you very much for any guidance or tip.
Updated:
Some info on the subject:
1) Heroku pre-installs both unixODBC and FreeTDS by default, so you already have them.
2) Also, it is possible to run shell commands via Heroku Console in backticks, e.g.:
heroku console
`odbcinst`
(runs "odbcinst" command in Heroku shell and shows the result)
3) You do not have access to filesystem outside of your slice where the packages are installed. If you only need a driver path, Heroku support can provide it (/usr/lib/odbc/libtdsodbc.so in my case).
4) You cannot run sudo commands in Heroku shell.
At the moment, to connect to MS SQL Server you at least need to append ‘freetds.conf’ file. Even when using tinyTDS (there is an open ticket#2 in tinyTDS gitgub issue page). DSN-less connection instructions from "wiki.rubyonrails.org SLASH database-support SLASH ms-sql" didn’t work for me, I guess this connection requires some extra-configuration either.
‘freetds.conf’ cannot be modified without sudo. Therefore, I conclude that currently there is no way to make MS SQL and Heroku work together.
I’ve managed to set up this connection with EngineYard and activerecord-sqlserver-adapter.
I followed these instructions:
https://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Platform-Installation---Ubuntu
(there are only some filepath differences, e.g. ‘odbc.ini’ is located in ‘/etc/unicodbc’, not in ‘/etc’ - this is easy to work out).
I installed 'unixODBC' and 'freetds' packages using EY Unix Packages feature, and made all configurations manually through SSH. Sudo is available in EY (no password required). There is also Chef Recepes feature to automate those configurations (seems to be pretty easy, I'm going to try it tomorrow).
Hope this is helpful.
It is possible.
Because Heroku copies/symlinks its own config/database.yml over whatever you supply in your repository, you may need to take additional steps (e.g. in config/environments/production.rb or in config/initializers/remote_mssql_from_heroku.rb) to set up your application appropriately.
You will face the challenge, however, that traffic from Heroku to your MSSQL database will traverse the public internet. By default, this traffic will not be encrypted. Potentially everyone in the world will be able to monitor your traffic between your Heroku application and your database, and even alter the traffic in-flight, whether for benign or malicious purpose, without you being able to detect it. MS SQL offers the capability to connect over SSL. This capability requires explicit configuration in the MSSQL server, so you must be able to access and modify that configuration. Additionally, this configuration requires that your client library be up-to-date and capable of talking with MSSQL over SSL. Note that MSSQL server will enforce that your server certificate list a Common Name or Subject Alternative Name exactly matching or wildcard-matching the server's FQDN (at least, the FQDN that the server knows about), and that the client use an FQDN for the server exactly matching or wildcard-matching one of the names on the certificate.
I've successfully used the following article which uses Heroku's newer buildpack feature to use TinyTDS and connect remotely to SQL Server 2008 R2. I'm still investigating how I could encrypt traffic. Hope this helps others!
http://blog.firmhouse.com/connecting-to-sql-server-from-heroku-with-freetds-here-is-how-on-cedar#
We're having a similar problem where we're needing to import old data from a SQL Server database into our new app. The data isn't a straight table import, but needs to undergo some processing and conversions. We've built an import layer for this which lives in a private gem, so as to not pollute the new app with the old data conversion issues. This approach is also designed to permit incremental updates, as we get closer to launch we'll keep syncing records up to the moment of switch-over.
Heroku told us that it's not trivial to connect to SQLServer, in particular as they don't support FreeTDS. Their support staff recommended to run an instance with the import gem from a laptop in our office and configure it to connect to their database (which requires a dedicated DB, not the free shared one). This sounded like the most palatable approach to us.
Secondly, regarding security that was mentioned by #Justice, we discussed configuring SSL for SQLServer with the hosting company and they pointed out the complexities of this. They recommended VPN as an easier solution. As we don't have office-side VPN hardware, the simplest and free solution proved to be an SSH tunnel.
We've set up an SSH tunnel from the laptop to the SQLServer Windows box. That was straightforward. We had CopSSH installed on Windows (which comes with a Linux shell, by the way) and we were able to simply set up a tunnel, having the laptop talk to localhost for its SQLServer connection, i.e.:
ssh -L 1433:localhost:1433 user#windows_server_name
I did not know Heroku has FreeTDS on it? I was told they did not. TinyTDS if used with FreeTDS 0.91 can have a zero freetds.conf dependency and be driving by runtime connection args. We are looking into building an Ubuntu 10.4 native gem that statically links 0.91 with OpenSSL so you can just drop it into Heroku and us it to connect to Azure and/or you own outside DB.