【问题标题】:JayRock Intermittent Missing ValuesJayRock 间歇性缺失值
【发布时间】:2013-08-23 20:24:08
【问题描述】:

我在使用 JayRock 时遇到问题,我间歇性收到 缺失值错误。

我无法重现该错误,但它每天在生产中发生大约 100-150 次(在数万个请求中)。

经过调查发现 在失败的请求中没有 [RequestBody] 元素 HTTP 请求。

通常看起来像这样:

[网址]

[RequestBody] {"id":1,"method":"getAllAirports","params":[]}

[cookies]

但是在它没有工作的情况下,请求包含:

[网址]

[cookies]

我正在使用默认的 JayRock 代理,并通过使用 ?test 页面 请求总是有效的。

以前有人遇到过这种情况吗?或者有什么想法?

非常感谢,

伊恩

更新: 从数据上看,似乎完全是 IE 的错误,IE7、8、9 和 10 都有错误。虽然 8 的错误最多,但它的流量与 9 相当,不到 10。

【问题讨论】:

    标签: c# javascript json rpc jayrock


    【解决方案1】:

    似乎是来自 Jayrock 的解析问题 http://jayrock.googlecode.com/hg/src/Jayrock.Json/Json/JsonTextReader.cs

    private JsonToken Parse()
        {
            char ch = NextClean();
    
            //
            // String
            //
    
            if (ch == '"' || ch == '\'')
            {
                return Yield(JsonToken.String(NextString(ch)));
            }
    
            //
            // Object
            //
    
            if (ch == '{')
            {
                _reader.Back();
                return ParseObject();
            }
    
            //
            // Array
            //
    
            if (ch == '[')
            {
                _reader.Back();
                return ParseArray();
            }
    
            //
            // Handle unquoted text. This could be the values true, false, or
            // null, or it can be a number. An implementation (such as this one)
            // is allowed to also accept non-standard forms.
            //
            // Accumulate characters until we reach the end of the text or a
            // formatting character.
            // 
    
            StringBuilder sb = new StringBuilder();
            char b = ch;
    
            while (ch >= ' ' && ",:]}/\\\"[{;=#".IndexOf(ch) < 0) 
            {
                sb.Append(ch);
                ch = _reader.Next();
            }
    
            _reader.Back();
    
            string s = sb.ToString().Trim();
    
            if (s.Length == 0)
                throw SyntaxError("Missing value.");
    
    
            //
            // Boolean
            //
    
            if (s == JsonBoolean.TrueText || s == JsonBoolean.FalseText)
                return Yield(JsonToken.Boolean(s == JsonBoolean.TrueText));
    
            //
            // Null
            //
    
            if (s == JsonNull.Text)
                return Yield(JsonToken.Null());
    
            //
            // Number
            //
            // Try converting it. We support the 0- and 0x- conventions. 
            // If a number cannot be produced, then the value will just
            // be a string. Note that the 0-, 0x-, plus, and implied 
            // string conventions are non-standard, but a JSON text parser 
            // is free to accept non-JSON text forms as long as it accepts 
            // all correct JSON text forms.
            //
    
            if ((b >= '0' && b <= '9') || b == '.' || b == '-' || b == '+')
            {
                if (b == '0' && s.Length > 1 && s.IndexOfAny(_numNonDigitChars) < 0)
                {
                    if (s.Length > 2 && (s[1] == 'x' || s[1] == 'X'))
                    {
                        string parsed = TryParseHex(s);
                        if (!ReferenceEquals(parsed, s))
                            return Yield(JsonToken.Number(parsed));
                    }
                    else
                    {
                        string parsed = TryParseOctal(s);
                        if (!ReferenceEquals(parsed, s))
                            return Yield(JsonToken.Number(parsed));
                    }
                }
                else
                {
                    if (!JsonNumber.IsValid(s))
                        throw SyntaxError(string.Format("The text '{0}' has the incorrect syntax for a number.", s));
    
                    return Yield(JsonToken.Number(s));
                }
            }
    
            //
            // Treat as String in all other cases, e.g. when unquoted.
            //
    
            return Yield(JsonToken.String(s));
        }
    

    【讨论】:

    • 请详细说明问题出在哪里,以便帮助 Op 找到解决方案
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-18
    • 2011-10-21
    • 1970-01-01
    • 1970-01-01
    • 2017-04-19
    • 1970-01-01
    相关资源
    最近更新 更多