Starcounter / Home

Starcounter is an in-memory database application engine.
https://starcounter.io
27 stars 1 forks source link

Newtonsoft.Json.JsonReaderException: Unterminated string. Expected delimiter: ". Path '[10].path', line 1, position 992 #187

Closed zafrul-adfenix closed 7 years ago

zafrul-adfenix commented 7 years ago

Hi , I am having a problem Starcounter polymer page. When I browse a page where there are number of rows and I can set page size. Upto page size 20 every thing is working fine. But when I make page size more than 20 it break and I get the following error:

Connection error: WebSocket connection closed. (1011) WS ws://79.adfenix.com/__default/7A6E82777E707B3080000070 Newtonsoft.Json.JsonReaderException: Unterminated string. Expected delimiter: ". Path '[10].path', line 1, position 992.

Here is the html:

<template>
        <paper-drawer-panel id="drawerPanel" responsive-width="900px" drawer-width="272px" disable-edge-swipe>
            <config-left-sidebar drawer></config-left-sidebar>
            <paper-header-panel id="container" main view="table" mode="scroll">
                <div id="content">
                    <div class="paper-header">
                        <h2 class="flex">Notification Filters</h2>
                    </div>

                    <div class="list-view">
                        <div class="header horizontal layout">
                            <div class="name flex-2">Filter Type</div>
                            <div class="name flex-2">Order By</div>
                            <div class="name flex-2">Group By</div>
                            <div class="name flex-2">Keyword in message</div>
                            <div class="action flex-1">Archived Status</div>
                            <div class="action flex-1">Page Size</div>
                        </div>
                        <div class="row horizontal layout" data-index$="{{index}}">
                            <div class="name flex-2">
                                <paper-dropdown-menu label="Filter Type">
                                    <paper-listbox class="dropdown-content" selected="{{model.SelectedAdminNotificationType$}}" attr-for-selected="value">
                                        <template is="dom-repeat" items="{{model.AdminNotificationTypes}}" as="AdminNotificationType">
                                            <paper-item value="{{AdminNotificationType.Name}}">{{AdminNotificationType.Name}}</paper-item>
                                        </template>
                                    </paper-listbox>
                                </paper-dropdown-menu>
                            </div>
                            <div class="name flex-2">
                                <paper-dropdown-menu label="Order by Column">
                                    <paper-listbox class="dropdown-content" selected="{{model.SelectedAdminNotificationOrder$}}" attr-for-selected="value">
                                        <paper-item value="Name">Type</paper-item>
                                        <paper-item value="Message">Message</paper-item>
                                        <paper-item value="Source">Source</paper-item>
                                        <paper-item value="Dated">Dated</paper-item>
                                    </paper-listbox>
                                </paper-dropdown-menu>
                            </div>
                            <div class="name flex-2">
                                <paper-dropdown-menu label="Group by Type">
                                    <paper-listbox class="dropdown-content" selected="{{model.SelectedAdminNotificationGroup$}}" attr-for-selected="value">
                                        <template is="dom-repeat" items="{{model.AdminNotificationTypes}}" as="AdminNotificationType">
                                            <paper-item value="{{AdminNotificationType.Name}}">{{AdminNotificationType.Name}}</paper-item>
                                        </template>
                                    </paper-listbox>
                                </paper-dropdown-menu>
                            </div>
                            <div class="name flex-2">
                                <paper-input name="Name" label="Search Keyword in message" value="{{model.SelectedMessageFilter$::change}}" required></paper-input>
                            </div>

                            <div class="action flex-1">
                                <div class="name flex-1"><p><input type="Checkbox" checked='{{model.DisplayArchive$::change}}'></p></div>
                            </div>
                            <div class="action flex-1">
                                <paper-input name="Name" label="Paging Size" value="{{model.AdminNotificationsPageSize$::change}}"></paper-input>
                            </div>
                        </div>
                    </div>
                </div>
                <div id="content">
                    <div class="paper-header">
                        <h2 class="flex">Admin Notifications</h2>
                    </div>
                    <div id="page-menu" class="horizontal top-b layout end" style="clear: both; display: block; position: relative; width: 100%;">
                        <div class="left-buttons" style="position: relative; left: 0; width: 40%; text-align: left; height: 80px;">
                            <div class="action flex-1" style="position: absolute; left: 80px; top: 36px;"><span> Page {{model.AdminNotificationsPageNo }}</span> of <span>{{model.TotalNumberOfPages}}</span></div>
                            <paper-icon-button id="archiveItems" class="main-button" style="margin-right: 10px; position: absolute; left: 0; top: 30px" on icon="archive" role="button" tabindex="0" aria-label="archive" cross-fade-delayed="" on-tap="globalArchiveOnTap"></paper-icon-button>
                        </div>
                        <div class="right-buttons" style="position: absolute; right: 20px; top: 30px; width: 100px; text-align: left; height: 80px;">
                            <paper-icon-button id="previousItems" class="main-button " style="margin-right: 10px; position: absolute; left: 0;" on icon="arrow-back" role="button" tabindex="0" aria-label="archive" cross-fade-delayed="" on-tap="loadPreviousItems"></paper-icon-button>
                            <paper-icon-button id="nextItems" class="main-button" on icon="arrow-forward" role="button" style="position:absolute; right:0;" tabindex="0" aria-label="archive" cross-fade-delayed="" on-tap="loadNextItems"></paper-icon-button>

                        </div>
                        <div class="list-view">
                            <div class="header horizontal layout">
                                <div class="name flex-1"><paper-checkbox id="checkbox" checked="{{model.GlobalCheck$}}" on-change="globalCheckOnChange"></paper-checkbox></div>
                                <div class="name flex-2">Type</div>
                                <div class="name flex-4">Message</div>
                                <div class="name flex-2">Source</div>
                                <div class="name flex-1">Dated</div>
                                <div class="name flex-1">Archive</div>
                                <div class="action flex-1">Action</div>
                            </div>
                            <template is="dom-repeat" items="{{model.AdminNotifications}}">
                                <div class="row horizontal layout" data-index$="{{index}}" style="margin:inherit;">
                                    <div class="name flex-1"><p><paper-checkbox checked="{{item.Check$::change}}" on-change="checkOnChange"></paper-checkbox></p></div>
                                    <div class="name flex-2 break-word-in-table">{{item.Name}}</div>
                                    <div class="name flex-4 break-word-in-table">{{item.Message}}</div>
                                    <div class="name flex-2 break-word-in-table">{{item.Source}}</div>
                                    <div class="name flex-1 break-word-in-table">{{item.Dated}}</div>
                                    <div class="name flex-1"><p><input type="Checkbox" checked='{{item.Archive$::change}}'></p></div>
                                    <div class="action flex-1">
                                        <admin-notifications-menu item="{{item}}"></admin-notifications-menu>
                                    </div>
                                </div>
                            </template>
                        </div>
                        <paper-dialog id="businessuniteditor">
                            <div>
                                <edit-admin-notifications item="{{model.CurrentAdminNotification}}"></edit-admin-notifications>
                            </div>
                        </paper-dialog>
                    </div>
                </div>
            </paper-header-panel>
        </paper-drawer-panel>
    </template>
    <script>
        Polymer({
            is: "admin-notifications",
            properties: {
                usergroup: {
                    type: String,
                    value: ""
                }
            },
            loadPreviousItems: function (e){
                this.model.Previous$++;

            },
            loadNextItems: function (e) {
                this.model.Next$++;
                this.set("model.GlobalCheck$", false);
            },
            globalArchiveOnTap: function (e) {
                this.model.GlobalArchive$++;
                this.set("model.GlobalCheck$", false);
            },

            globalCheckOnChange: function (e) {
                var state = this.$.checkbox.checked;
                var self = this;
                this.model.AdminNotifications.forEach(function (item, index) {
                    self.set('model.AdminNotifications.' + index + '.Check$', state);
                });
            },
            checkOnChange: function (e) {
                this.set("model.GlobalCheck$", false);
            },
            listeners: {
                'webMasterEditor': 'openWebMasterEditor',
                'businessUnitEditor': 'openBusinessUnitEditor',
            },           
            openBusinessUnitEditor: function (e, id) {
                this.async(function () {
                    this.$.businessuniteditor.open();
                });
            }
        });
    </script>

Here is strongly typed json:

{
  "$": { "Namespace": "AdFenix.Backoffice.Configuration.json" },
  "Html": "/Configuration/html/adminnotification.html",
  "ObId": "",
  "RedirectUrl$": "",
  "SelectedMessageFilter$": "",
  "SelectedAdminNotificationType$": "",
  "SelectedAdminNotificationOrder$": "",
  "SelectedAdminNotificationGroup$": "",
  "AdminNotificationsPageSize$": 10,
  "AdminNotificationsPageNo": 1,
  "$AdminNotifications": { "Bind": "AdminNotifications_" },
  "AdminNotifications": [
    {
      "ObId": "",
      "Check$": false,
      "Name": "SuccessAudit",
      "Message": "System is UP",
      "StackTrace": " ",
      "Source": "",
      "Dated": "2016/10/10 10:18:10",
      "ServerIp": "localhost",
      "Archive$": false,
      "TrelloCard$": ""
    }
  ],
  "AdminNotificationTypes": [
    {
      "Name": ""
    }
  ],
  "SelectedAdminNotificationID$": "",
  "$CurrentAdminNotification": { "Bind": "CurrentAdminNotification_" },
  "CurrentAdminNotification": {
    "ObId": "",
    "Name": "",
    "Message": "",
    "StackTrace": " ",
    "Source": "a",
    "NotificationCount": 0,
    "Dated": "2016/10/10 10:18:10",
    "ServerIp": "localhost",
    "TrelloCard$": "asdsa",
    "Save$": 0
  },
  "GlobalArchive$": 0,
  "TotalNotificationCount$": 0,
  "TotalNumberOfPages": 0,
  "TotalNotificationCountPerPage$": 0,
  "DisplayArchive$": false,
  "GlobalCheck$": false,
  "Next$": 0,
  "Previous$": 0
}

This is the main event getting called for binding:

 public IEnumerable AdminNotifications_
        {
            get
            {
                if (this.AdminNotificationTypes.Count == 0)
                {
                  .........

                    {
                        .....
                        .. = Db.SQL<AdFenix.Database.AdminNotification>("SELECT an FROM db an WHERE Name = ? and archive = ? fetch ?", Name, DisplayArchive, 1).First;

                    }
                }
              return   QueryResultRows<Database.SomeTable> adminNotificationList = GetAdminNotifictionsPage(,,);
                return adminNotificationList;
            }

        }
Mackiovello commented 7 years ago

This is a duplicate of an issue we have in our internal issue tracker. I've bumped that issue.

How urgent is this for you?

zafrul-adfenix commented 7 years ago

Yes it is urgent. It would be nice if I can solve this by today.

miyconst commented 7 years ago

@Mackiovello please explain the reason of the issue and how to avoid it, if that is possible.

Mackiovello commented 7 years ago

@Mackiovello please explain the reason of the issue and how to avoid it, if that is possible.

There is a limit to the size of patches. The only solution is to limit the size of patches. That's everything I know.

zafrul-adfenix commented 7 years ago

The code I have already posted. The page is just showing list of data in a table. Each row has a checkbox. When we select all the rows with checkboxes checked, and want to do on action on all the rows, it works 20 rows. But when I increase the rows to 40,50 or 100 and I check all the rows checked, it immediately throws exception. Problem is I cannot get the error while I debug in local.

zafrul-adfenix commented 7 years ago

Can you provide me an example to limit the size of of patches.

Mackiovello commented 7 years ago

Problem is I cannot get the error while I debug in local.

Yes, this issue doesn't seem to be consistent from machine to machine, I've hit that too.

Could you check if you're getting this exception in the log:

System.Exception: Unknown WebSocket frame type: 0
   at Starcounter.GatewayHandlers.HandleWebSocket(UInt16 managedHandlerId, Byte* rawChunk, BMX_TASK_INFO* taskInfo, Boolean* isHandled) in c:\users\christian\code\Starcounter\Versions\v2.3\Level1\src\Starcounter\Apps\GatewayHandlers.cs:line 771
HResult=-2146233088

Can you provide me an example to limit the size of of patches.

I don't have a good answer, but from the client I guess you could setInterval and send the changes in smaller chunks by splitting them and sending them over in packages and then toggling a flag when everything is sent. That seems hacky, though. I'm not sure how it would be done from the server-side. Again, I'm not the expert on this.

@alemoi or @warpech could you please help out here?

zafrul-adfenix commented 7 years ago

I got this error message in log:

System.Exception: Unknown WebSocket frame type: 0
   at Starcounter.GatewayHandlers.HandleWebSocket(UInt16 managedHandlerId, Byte* rawChunk, BMX_TASK_INFO* taskInfo, Boolean* isHandled) in C:\TeamCity\TeamCity10\buildAgent\work\sc-3487\Level1\src\Starcounter\Apps\GatewayHandlers.cs:line 719
HResult=-2146233088
SenerDemiral commented 7 years ago

https://github.com/Starcounter/Home/issues/65

ghost commented 7 years ago

I am working on fixing WebSocket fragmentation actually now. Hopefully very soon providing support!

ghost commented 7 years ago

The support for fragmentation is added and tested via Autobahn. Hope you enjoy this feature 😄

zafrul-adfenix commented 7 years ago

@alemoi Hi how would I apply this change. Do I need to update the star counter or any dll?

ghost commented 7 years ago

@zafrul-adfenix the nightly failed because of insufficient disk space, but I have produced a new build for you: http://downloads.starcounter.com/download/Starcounter/Custom/2.3.1.6885 You need an update of Starcounter.