locked
Using WebSocket JS in Windows 8.1 app. Where is the mistake? RRS feed

  • Question

  • There is a script in php working with WebSocket, as he wrote himself at the time of writing there was no ready-made solutions 

    initialization:

    $host = '192.168.10.225'; //host
    $port = '3994'; //port
    
    //Create TCP/IP sream socket
    $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
    //reuseable port
    socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1);
    
    //bind socket to specified host
    socket_bind($socket, 0, $port);
    
    //listen to port
    socket_listen($socket);

    And the client code (His warp over WebSocket):

    Socket.bind('open', function () {
                Socket.send({ name: 'alex', status: 'online' });
            });
    
            Socket.init("ws://192.168.10.225:3994/shell/rest.sock.php");
    ...
    var Socket = (function(){
        var socket;
    
        var self = {
            init: function(host){
                socket = new WebSocket(host);
        
                socket.onopen    = function(e){ callEventList('open', e) };
                socket.onmessage = function(e){ callEventList('message', e) };
                socket.onclose   = function(e){ callEventList('close', e) };
            },
            send: function (msg) {
    ...

    Works everywhere: chrome / opera / ie / android / ios 
    But when trying to connect to the Windows store app js, produces an error: 
    SCRIPT12029: WebSocket Error: Network Error 12029, Unable to communicate with the server 
    Which is strange because The same code works ie 
    Prompt where it may be a mistake to look for and where?

    Sorry for my eng...

    Sunday, July 6, 2014 7:10 PM

Answers

  • Hi,

    I tried to understand your code but then I recognized the code should be ok because it works with ie, Windows Store App use IE render engine.

    I guess the error could be thrown when the app network capability is not enabled, see this for more information: App capability declarations.

    Another possibility is you are trying to connect localhost which is not allowed in Windows Store App.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, July 7, 2014 5:24 AM
    Moderator