dkuppitz / rexpro-client

RexPro Client for .NET
Other
10 stars 4 forks source link

Unexpected message header #2

Closed m1sta closed 11 years ago

m1sta commented 11 years ago

Thanks releasing the RexPro client. I've just installed it and am receiving an unhelpful exception. I'm new to the space, apologies if I have missed something obvious.

I'm receiving the following exception... Rexster.RexProClientSerializationException {"Unexpected message header."} at Rexster.RexProClient.SendRequest[TRequest,TResponse](TRequest message, Byte requestMessageType) at Rexster.RexProClient.ExecuteScript[T](ScriptRequest script, RexProSession session, Boolean isolate, Boolean transaction) at Rexster.RexProClient.Query[T](String script, Dictionary`2 bindings, RexProSession session, Boolean isolate, Boolean transaction) at TitanTest.Default.Page_Load(Object sender, EventArgs e) in c:\Users...\TitanTest\Default.aspx.cs:line 16 at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

When trying to run the following... var client = new RexProClient("127.0.0.1", 8182); var result = client.Query("g.V.count()");

The environment I'm using is... Windows 7 64bit .Net Framework 4.5.50709 http://s3.thinkaurelius.com/downloads/titan/titan-berkeleyje-0.3.0.zip Running rexster with default parameters RexPro client 1.0.4859.34136

The same query runs fine when using the Rexster Console to connect to Titan.

m1sta commented 11 years ago

I have no such problem when running var client = new RexProClient(); var result = client.Query("g.V.count()");

Is there any reason why including the server's IP address and port when creating the RexProClient should change the message serialisation?

dkuppitz commented 11 years ago

Rexsters default port for RexPro is 8184. Port 8182 is for the REST endpoint.

Also make sure that either your graph is named graph in the graph section or you provide the graph settings in RexProClients.constructor, for example:

var settings = new GraphSettings("your-graph-name")
var client = new RexProClient("127.0.0.1", 8184, settings);

When you're using Titan server, you don't need to care about the graph name setting, it will just work.

Also note that localhost and 8184 are the default values for RexProClient constructor, so you can also simply create a client without passing any constructor argument:

var client = new RexProClient();
glikoz commented 11 years ago

We have same problem, the problem happens for long (ex. 1500 characters) string properties. titan-berkeleyje-0.3.1.zip

dkuppitz commented 11 years ago

Are you sure, you're using the right port and graph name? It would probably help when you show the code you use to initialize the client and your Rexster configuration.

glikoz commented 11 years ago

We are sending all strings with triple quotes to execute. We suspect that problem is related with it. Without triple quotes everything seems ok. Sample: 'Type':\"\"\"\r\nArticle\"\"\" We had to do this because some of the properties are multi-line strings.(Article.Html) This is the problematic gremlin query:

g.addVertex(['ContentAsString':\"\"\"\r\nPROBLEM_CONTENT...........\n\"\"\",'ShortDescription':\"\"\"\r\nasdasdasdasasdsad adssadsadasddsd saddsdasdasdasdasasdsad a dssadsadasddsd saddsdasdasdasdasasdsad adssadsadasddsd saddsdasdasdasdasasdsad adssadsadasddsd saddsdasdasdasdasasdsad adssadsadasddsd saddsd\"\"\",'OriginalityScore':0,'SiteId':8L,'Name_English':\"\"\"\r\nasdjkh askjhd kajshdkjashdkjh\"\"\",'Td':0L,'Type':\"\"\"\r\nArticle\"\"\",'State':2,'CreateDate':'19.06.2013 00:12:49 +03:00','UpdateDate':'01.01.0001 00:00:00 +00:00','PublishDate':'19.06.2013 00:12:49 +03:00'])

When PROBLEM_CONTENT is short it runs but when it is long we are getting "Unexpected Header" exception

dkuppitz commented 11 years ago

Can you provide a code sample to reproduce it? I've tried it with 3000+ characters:

public void LongText()
{
    string text;

    using (var wc = new WebClient())
    {
        text = wc.DownloadString("http://loripsum.net/api/5/long/plaintext");
    }

    const string script = "g = new TinkerGraph();" +
                          "g.addVertex(['text':text]).map()";

    var parameters = new Dictionary<string, object>
    {
        {"text", text}
    };

    var vertex = client.Query(script, parameters);

    Assert.IsNotNull(vertex);
    Assert.AreEqual(text, vertex.text);
}

No problem at all.

glikoz commented 11 years ago

I'm trying to reproduce issue: g.addVertex(['text':""" 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1234678 1"""]) this is failed for our configuration.

glikoz commented 11 years ago

This is also critical length for our configuration if there is one character less it works. Our configuration berkeley 0.3.1

dkuppitz commented 11 years ago

Ok, tried it on Berkeley, but again no problem at all. Here're my test methods:

[TestMethod]
public void LongText()
{
    string text;

    using (var wc = new WebClient())
    {
        text = wc.DownloadString("http://loripsum.net/api/5/long/plaintext");
    }

    var script = string.Format("g.addVertex(['text':'''{0}''']).map()", text);
    var vertex = client.Query(script);

    Assert.IsNotNull(vertex);
    Assert.AreEqual(text, vertex.text);
}

[TestMethod]
public void LongTextParams()
{
    string text;

    using (var wc = new WebClient())
    {
        text = wc.DownloadString("http://loripsum.net/api/5/long/plaintext");
    }

    const string script = "g.addVertex(['text':text]).map()";

    var parameters = new Dictionary<string, object>
    {
        {"text", text}
    };

    var vertex = client.Query(script, parameters);

    Assert.IsNotNull(vertex);
    Assert.AreEqual(text, vertex.text);
}

If you have line breaks in your property values, make sure to use Groovys multi-line syntax

Or even better: Use parameters (see my seconds test method). With parameters you don't have to care about esaping, multi-line syntaxes, etc.

glikoz commented 11 years ago

We will try tomorrow, I dont want to share our test server adress. But we have to share, if we can not detect the problem.. Thanks.

glikoz commented 11 years ago

Hi @dkuppitz, Is there any security option for RexterPro Client. If there is I will give to you our server adresses.

Best regards.

glikoz commented 11 years ago

Weird. When we are using breakpoint and execuıting code step by step there is no error. We suspect that UnPacker reads data from NetworkStream but when network speed is slow then problem is occuring.

dkuppitz commented 11 years ago

Please contact me via Skype tomorrow. I can have a look at it via TeamViewer.

Gesendet von meinem Windows Phone


Von: glikoz Gesendet: 20.06.2013 23:07 An: dkuppitz/rexpro-client Cc: Daniel Kuppitz Betreff: Re: [rexpro-client] Unexpected message header (#2)

Weird. When we are using breakpoint and execuıting code step by step there is no error. We suspect that UnPacker reads data from NetworkStream but when network speed is slow then problem is occuring.


Reply to this email directly or view it on GitHub: https://github.com/dkuppitz/rexpro-client/issues/2#issuecomment-19783410