0

I'm working on a school project. The goal is to link a Windows Phone 8 (WP8) with a server (node.js using sails.js framework based on express.js) by TCP socket.

I have found a great tutorial for the C# part (WP8), I'm working with a Windows 8 Virtual Machine but it's not an issue. (Just slow an borring -_-)

Based on the tutorial, I "realized" the WP part. I realized also the node.js server, using socket.io.

Here the WP8 tutorial: http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh202858(v=vs.105).aspx

Here my WP8 application (8.0): (Based on the tutorial but customized)

SocketClient: http://pastebin.com/8ncad4EV

MainPage.cs: http://pastebin.com/5VAU96JV

Mainpage.xaml.cs: http://pastebin.com/hhvmQvPS

Here, a screenshot of the application + node.js server side source code: WP8 and node server

On the left screen you can see the server side code which create "listeners". At right the VM with WP8 and the emulator. As you can see, I can connect to my server using socket. But I don't get any response.

About server logs, there is no log created when I run the WP8 application, it's writted than the connection is a success but no log on the server about it.

You can see the website directly here: 137.135.176.144:1337 and you can use the javascript console for run tests if you want, like:

socket.emit('disconnection', function(res){console.log(res);});

You will see a response from the server about you are disconnected (it's just a log, not true) and I will get it on my own console, server side.

But when I try to connect with WP8 or netduino (because I have to connect netuido and WP8 using sockets with node.js) it's the same. No error during connection but no response.

So, I'm here because I'm noobie about node.js and I tried a lot of things but still the same. Could you help me? Thank you.


I'm trying something else. Another code client side (WP8). Because I was running synchronious requests, I'm trying to run asynchronious now, because the node.js server is asynchrone:

Source code

You can create a new project, add this class and call it in the "main" function.

Output:

Application proccessing...
Application started
Operation processing: Connect
Connect: Successful connection etablished to Unspecified/137.135.176.144:1337
Operation processing: Send
Operation processing: Receive
Data received: connection (10)

Date received is equal to the data I sent myself (you can see it line 70). I don't get data from the server (Or I do it wrong) and I don't see any connection on the server console.

As you can see I'm not sure to call the good URL, but if I write http:// before the IP address, the program throw a SocketException: "No such host is known"

An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Net.Sockets.SocketException' occurred in System.Net.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.Net.Sockets.SocketException' occurred in SocketsTest.DLL

I don't understand why it throw an error with http://. The source code server side is the same than before.

Could you help me? I'm pretty lost here. Thank you.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
Vadorequest
  • 16,593
  • 24
  • 118
  • 215
  • 1
    i have no great knowledge on c# , but `socket.io` client doesn't seem to be `socket.io` compactible.. you should really use some of the client from socket.io wiki https://github.com/LearnBoost/Socket.IO/wiki, remember `socket.io` its not TCP its Websockets – Gntem Oct 01 '13 at 05:48
  • Yeah. Probably, thank you I'm looking for a solution probably use socket.io server side and no websocket. I took a look of your link but there is nothing useful for me, I'm working with C# and the only one available works only for 4.0 .NET. https://socketio4net.codeplex.com/ – Vadorequest Oct 01 '13 at 10:23
  • well on other side, wp8 programming is done with javascript, tried to include `socket.io-client` in javascript? – Gntem Oct 01 '13 at 11:48
  • I read somewhere that I could use a frame with a kind of browser inside in WP and by this way I could use the website directly. But, I have another issue, I need to connect with the netduino, using socket.io or websocket, but websocket don't really exists in .NETMF... – Vadorequest Oct 01 '13 at 17:26
  • A friend just told me that sails.js used socket.io, not websocket. And it's probably true because the script client side is named socket.io.js ^^ So... it's because of something else, maybe? I want to ask to the staff/support but not answer yet. – Vadorequest Oct 01 '13 at 18:15
  • 1
    Have you read over the Socket.io protocol doc at https://github.com/LearnBoost/socket.io-spec? Are you performing the Socket.io handshake when you first connect, to get the session ID, and are you sending your requests to the correct URI (http://137.135.176.144:1337/socket.io/1/websocket/[session id]) ? – sgress454 Oct 02 '13 at 20:12
  • I didn't knew all these things, but after read the documentation, it works with direct http. But I can't use it with my phone/netduino (.NET C#) it's a TCP connection which is required, with this kind of source code (WP8) http://pastebin.com/5VAU96JV I have a request timeout from the phone, using TCP connection and following this tutorial: http://www.sebastianseilund.com/json-socket-sending-json-over-tcp-in-node.js-using-sockets I can only choose the host and the port, nothing else, so I can't get the id or something, it's not the good way... I don't understand. Thank you for help. – Vadorequest Oct 03 '13 at 22:33
  • Read about specification doesn't helped me. But it was interesting. Anyway, it's not the good way I thing, because I can't call this kind of URL using .NET native objects/methods... – Vadorequest Oct 07 '13 at 14:52

0 Answers0