Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
bekahbeets
Creator
Creator

Connecting to localhost gives websocket error

I am getting started with qlik desktop and I have connected to the desktop via Visual Studio plugin. I have added 2 sheets to visual studio, but when i debug to localhost, I get errors

In .js file...

var config = {

    host: window.location.hostname,

    prefix: '/',

    port: window.location.port,

    isSecure: window.location.protocol === "https:"

};

require.config( {

    baseUrl: (config.isSecure ? "https://" : "http://") + config.host + (config.port ? ":" + config.port : "") + config.prefix + "resources"

});

require(["js/qlik"], function(qlik) {

    // open the app

    var app = qlik.openApp('c31e2aba-3b46-4b13-8b87-c5c2514dea1d', config); //someone please tell me what this id is and where it comes from because I c&p'd off of the tutorials and idk what goes here

});

In VS:

<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="server">

        <div class="qlik-embed" data-qlik-appid="\\apfs01\users\rbeets\Documents\Qlik\Sense\Apps\app1.qvf" data-qlik-objid="ZCJjkN></div>

    <div class="qlik-embed" data-qlik-appid="\\apfs01\users\rbeets\Documents\Qlik\Sense\Apps\app2.qvf" data-qlik-objid="JRcLVC"></div>

</asp:Content>

and the errors 1 and 2:

Websocket connection to 'ws://localhost......aspx' failed. Error during Websocket handshake. Unexpected response code: 404

Uncaught Error: Mismatched anonymous define() module      ...from require.js:6

1 Solution

Accepted Solutions
bekahbeets
Creator
Creator
Author

So the first thing to do is forget what qlik tells you to do to connect to it. I used the javascript built in websocket commands to connect and it works fine for connection.

Tutorials: http://blog.teamtreehouse.com/an-introduction-to-websockets, websocket.org Echo Test - Powered by Kaazing

var socket = {};

             window.onload = function () {

                 // Get references to elements on the page. these are div fields and buttons in the html.

                 var form = document.getElementById('message-form');

                 var messageField = document.getElementById('message');

                 var messagesList = document.getElementById('messages');

                 var socketStatus = document.getElementById('status');

                 var closeBtn = document.getElementById('close');

                 // The rest of the code in this tutorial will go here...

                 var websocketURL = 'see_attached_pic_to_find_out_what_this_is';

                 var socketOnClose = function (msg) {

                     console.log('websocket disconnected - waiting for connection');

                     websocketWait();

                 };

                 var socketOnMessage = function (msg) {

                     console.log("RECEIVED ");

                     //console.log(msg.data);

                 };

                 var socketOnOpen = function (msg) {

                     console.log("websocket opened");

                     qlikJSONtoServer();

                 };

                 function websocketWait() {

                     setTimeout(function () {

                         socket = new WebSocket(websocketURL);

                         socket.onopen = socketOnOpen;

                         socket.onclose = socketOnClose;

                         socket.onmessage = socketOnMessage;

                     }, 1000);

                 };

                 websocketWait();

               function qlikJSONtoServer() {

                     // DocLIST/AppList

                     console.log("GET DOC/App LIST");

                    //from connect to engine command in qs engine-api-explorer

                     socket.send(JSON.stringify(

                       { "handle": -1, "method": "GetDocList", "params": [], "outKey": -1, "id": 1 }

                     ));

                    //continues with more commands from the engine api explorer...

               }

}

url for wss.PNG

View solution in original post

6 Replies
lathakatti
Contributor II
Contributor II

were u able to solve this ? I am facing the same issue.

bekahbeets
Creator
Creator
Author

So the first thing to do is forget what qlik tells you to do to connect to it. I used the javascript built in websocket commands to connect and it works fine for connection.

Tutorials: http://blog.teamtreehouse.com/an-introduction-to-websockets, websocket.org Echo Test - Powered by Kaazing

var socket = {};

             window.onload = function () {

                 // Get references to elements on the page. these are div fields and buttons in the html.

                 var form = document.getElementById('message-form');

                 var messageField = document.getElementById('message');

                 var messagesList = document.getElementById('messages');

                 var socketStatus = document.getElementById('status');

                 var closeBtn = document.getElementById('close');

                 // The rest of the code in this tutorial will go here...

                 var websocketURL = 'see_attached_pic_to_find_out_what_this_is';

                 var socketOnClose = function (msg) {

                     console.log('websocket disconnected - waiting for connection');

                     websocketWait();

                 };

                 var socketOnMessage = function (msg) {

                     console.log("RECEIVED ");

                     //console.log(msg.data);

                 };

                 var socketOnOpen = function (msg) {

                     console.log("websocket opened");

                     qlikJSONtoServer();

                 };

                 function websocketWait() {

                     setTimeout(function () {

                         socket = new WebSocket(websocketURL);

                         socket.onopen = socketOnOpen;

                         socket.onclose = socketOnClose;

                         socket.onmessage = socketOnMessage;

                     }, 1000);

                 };

                 websocketWait();

               function qlikJSONtoServer() {

                     // DocLIST/AppList

                     console.log("GET DOC/App LIST");

                    //from connect to engine command in qs engine-api-explorer

                     socket.send(JSON.stringify(

                       { "handle": -1, "method": "GetDocList", "params": [], "outKey": -1, "id": 1 }

                     ));

                    //continues with more commands from the engine api explorer...

               }

}

url for wss.PNG

View solution in original post

lathakatti
Contributor II
Contributor II

I really did not get this

var websocketURL = 'see_attached_pic_to_find_out_what_this_is';


Will the target id not change dynamically, on each request?? should I hardcode that url here??

lathakatti
Contributor II
Contributor II

How do I get the ticket Id from?

bekahbeets
Creator
Creator
Author

theres a pic attached to the comment.

I haven't got that far to get it from code, but when you execute a macro, the ticket id will be at the end of the url

rbartley
Specialist
Specialist

Thanks for this, I was able to connect and retrieve the list of apps.  I found that I didn't need to supply the TicketID.  I assume this was done by behind the scenes.