mfenniak / rethinkdb-net

A C# / .NET client driver for RethinkDB.
Other
247 stars 37 forks source link

Connecting to rethinkdbcloud.com #129

Closed jchannon closed 11 years ago

jchannon commented 11 years ago

I've created a free instance on rethinkdbcloud.com but can't connect using the below code. Is something wrong?

IConnection connection = 
  new RethinkDb.Connection(new EndPoint[] { new DnsEndPoint("http://shared1.rethinkdbcloud.com", 49268) });

connection.Connect();
jchannon commented 11 years ago

also tried:

IConnection connection =  new RethinkDb.Connection();

connection.AuthorizationKey = "mykey";
connection.EndPoints = new EndPoint[] { new IPEndPoint(IPAddress.Parse("192.241.199.61"), 49268), };

connection.Connect();
mfenniak commented 11 years ago

Hi Jonathan,

Can you describe what happens in more detail than "can't connect"? Do you get an exception, and if so, what does it say? Regarding your first example, putting "http://" into the DnsEndPoint constructor is a mistake that would prevent this from working correctly.

jchannon commented 11 years ago

Hi,

It just hangs on the Connect line.

Thanks

mfenniak commented 11 years ago

Is the port you're using the same port that you would use to connect in a web browser (eg. http://shared1.rethinkdbcloud.com:49268/)? If so, it's the port of the web interface, and not the correct port for any RethinkDB client to connect to. That seems like a likely cause of a hang on Connect().

ConceitedCode commented 11 years ago

Hi Guys,

I'm on the RethinkDB Cloud team and have confirmed with jchannon that he can connect with the same credentials using the Javascript client. The free instances are currently running RethinkDB 1.7.2 (updating new instances to 1.9 late tonight), maybe it has an issue connecting to older instances?

jchannon commented 11 years ago

Hi!

Here's the code that works in node.js

r = require('rethinkdb');

var connection = null;
r.connect( {host: 'shared1.rethinkdbcloud.com', port: 49268, authKey:'mykey'}, function(err, conn) {
    if (err) throw err;
    console.log('connected')
    connection = conn;
})
mfenniak commented 11 years ago

Hm, I can't see any reason why we wouldn't be compatible with RethinkDB 1.7 still, mostly. Some queries might not work correctly, but I can't see anything that would affect connecting. Is that auth key really "mykey"? Can I attempt to reproduce and debug this issue with that connection information?

jchannon commented 11 years ago

No its not "mykey", shall I email it to you?

ConceitedCode commented 11 years ago

The auth key is not actually "mykey". I will spin up an instance for you to reproduce/debug with and will delete the instance later tonight. Gimme 1 min and I'll post the credentials you will need to connect.

ConceitedCode commented 11 years ago

Here's an instance for you to try and I have confirmed it works with the Python client.

host: shared1.rethinkdbcloud.com port: 49269 auth key: ZXNF8A47H72V

jchannon commented 11 years ago

using async code it results in this - I assume after a timeout

RethinkDb.RethinkDbNetworkException: Failed to resolve a connectable address.
   at RethinkDb.Connection.c__async0.MoveNext()
mfenniak commented 11 years ago

I was able to run unit tests successfully against the database connection provided by @ConceitedCode (port 49269); although there are a few errors due to the incompatibility with RethinkDB 1.7, the connection worked just fine.

Against @jchannon's database (port 49268), I can't even establish a network connection with telnet, so this is probably why the Connect() method appears to hang:

[mfenniak@ux32vd apislice]$ telnet shared1.rethinkdbcloud.com 49269
Trying 192.241.199.61...
Connected to shared1.rethinkdbcloud.com.
Escape character is '^]'.
^]

telnet> quit
Connection closed.

[mfenniak@ux32vd apislice]$ telnet shared1.rethinkdbcloud.com 49268
Trying 192.241.199.61...
^C
ConceitedCode commented 11 years ago

Well that's strange. @jchannon, Do you mind double checking that you are still able to connect using the Javascript client?

jchannon commented 11 years ago

Connection failed :(

ConceitedCode commented 11 years ago

Doesn't look like it's on the client side. The instance @jchannon is trying to connect to has crashed for some reason. Thanks for the help @mfenniak.

@jchannon, I'll restart the instance for you and investigate why it crashed.

jchannon commented 11 years ago

I'm guessing all the attempts to connect to it crashed it!

jchannon commented 11 years ago

@mfenniak what would be your code recommendation on connecting?

mfenniak commented 11 years ago

Please re-open if the issue persists in some similar way, I'm glad to help out.

@jchannon, by the way, the code I'd recommend to create the database connection (back to your first two posts) would be this:

var connection = ConfigConnectionFactory.Instance.Get("testCluster");
connection.Connect();   // or   await connection.ConnectAsync();

Plus an App.config/Web.config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
        <section name="rethinkdb" type="RethinkDb.Configuration.RethinkDbClientSection, RethinkDb"/>
    </configSections>
    <rethinkdb>
        <clusters>
            <cluster name="testCluster" authorizationKey="mykey">
                <endpoints>
                    <endpoint address="shared1.rethinkdbcloud.com" port="12345"/>
                </endpoints>
            </cluster>
        </clusters>
    </rethinkdb>
</configuration>
mfenniak commented 11 years ago

Also, FYI, rethinkdb-net shouldn't have hung when attempting to connect. We have an outstanding issue (#62) relating to Connect not timing out properly as configured.

jchannon commented 11 years ago

I don't think the free instance is in a cluster so I assume that web.config approach would fail!

Thanks for the help

mfenniak commented 11 years ago

It will work. The "cluster" option in the config file just allows you to specify multiple endpoints. If you only specify one, it will only connect to one.

jchannon commented 11 years ago

Just to let you know I created a new instance and tested it with node and all ok.

Tested with C# and failed

 var connection = ConfigConnectionFactory.Instance.Get("testCluster");
connection.Connect();   // or   await connection.ConnectAsync();
var result = connection.Run(Query.DbCreate("movies"));

<configSections>
    <section name="rethinkdb" type="RethinkDb.Configuration.RethinkDbClientSection, RethinkDb"/>
  </configSections>

  <rethinkdb>
    <clusters>
      <cluster name="testCluster" authorizationKey="7WNTV6OMSEEW">
        <endpoints>
          <endpoint address="shared1.rethinkdbcloud.com" port="49275"/>
        </endpoints>
      </cluster>
    </clusters>
  </rethinkdb>
mfenniak commented 11 years ago

I've written a test program to connect to the new port 49275 database as you've indicated. It works for me. Can you please download this source archive, build it, and give it a try?

https://www.dropbox.com/s/2me876qjrfgj6h4/TestRethink.7z

jchannon commented 11 years ago

That connects fine!

Odd

My attempt was in a ASP.Net application

karlgrz commented 11 years ago

Confirm, I can connect using latest pull as well.

KG

On Tue, Sep 17, 2013 at 10:05 AM, Jonathan Channon <notifications@github.com

wrote:

That connects fine!

Odd

My attempt was in a ASP.Net application

— Reply to this email directly or view it on GitHubhttps://github.com/mfenniak/rethinkdb-net/issues/129#issuecomment-24595425 .

jchannon commented 11 years ago

I'm using nuget and Asp.Net

karlgrz commented 11 years ago

I just used Mathieu's build and was able to connect, as well.

Let me try and run as an ASP.net application instead of a console app.

KG

On Tue, Sep 17, 2013 at 10:18 AM, Jonathan Channon <notifications@github.com

wrote:

I'm using nuget and Asp.Net

— Reply to this email directly or view it on GitHubhttps://github.com/mfenniak/rethinkdb-net/issues/129#issuecomment-24596525 .

jchannon commented 11 years ago

Try using nuget and not the git repo

karlgrz commented 11 years ago

The build that Mathieu sent out uses v.0.4 of the rethinkdb-net driver from nuget. That's what I used the second time and was able to connect from his console app. My apologies for not clarifying.

I will use the same nuget package in this test web application.

Sorry for adding to confusion.

KG

On Tue, Sep 17, 2013 at 10:23 AM, Jonathan Channon <notifications@github.com

wrote:

Try using nuget and not the git repo

— Reply to this email directly or view it on GitHubhttps://github.com/mfenniak/rethinkdb-net/issues/129#issuecomment-24596980 .

mfenniak commented 11 years ago

There may be a problem with the nuget package; it has a dependency on "any version" of protobuf-net, but dropping the newest version in-place doesn't seem to work. This did cause me a runtime failure that I was able to get around by installing an explicit version of protobuf-net; however, it's not a Connect() failure as documented here, it was an assembly loading problem.

I'm going to go ahead and push a new version of the nuget package to fix this problem.

mfenniak commented 11 years ago

I've reproduced the reported issue under ASP.NET on Windows. It doesn't seem specific to rethinkdbcloud.com, so I've opened a new issue for it, #130, that I am populating with information right now.

jchannon commented 11 years ago

Thanks christ! Thought I was going mental :smile: If you need a hand let me know!

mfenniak commented 11 years ago

I thought you were going mental too, if that helps you feel any better. ;-) It's a weird issue, and the rethinkdbcloud.com involvement was a red herring that threw the investigation off. Thanks for reporting this and sticking with us to get a good diagnosis of the environment needed to reproduce it; whatever it is is a serious problem standing in the way of using rethinkdb-net in a web application.

jchannon commented 11 years ago

LOL!

I'm a NancyFX core contributor so I'm looking to get a demo up and running so I'll help out as much as I can