Websockets on Ionic

Has anyone got websockets to work with ionic?

I have it all working using the websocket-rails gem in the browser. What are the barriers to this working in the simulator?

Websocket-rails is built on top of a Faye server. Everything is being initialized correctly and in the right order and I have double checked all the channel and “dispatcher” settings and they are the same as in the browser.

When I trigger a new message, the message is not getting to the server dedicated websockets controller and so there are no messages coming back.

var dispatcher = new WebSocketRails(WEBSOCKETS);
dispatcher.trigger('messages.create', $scope.message);

var channel = dispatcher.subscribe("chat_room_" + $scope.chat_room.id);
channel.bind('new_message', function(data) { 
  //DO STUFF
});

It looks like recent versions of iOS should support websockets. Android maybe you have to add the plugin:

Although it works in the browser (chrome and safari), but I’m still having trouble in the emulator.

Websocket support has nothing to do with Ionic. I’ve never setup sockets in an app before, but Ionic is not stopping you from doing so.

Sorry, I saw you made a firebase implementation so I thought there might be some ionic stuff effecting websockets.

Fixed! it was an SSL problem.

1 Like

Hi What was your issue with SSL?

Im trying to use Ionic with Socket.io.

The chat app works in the browser,but not on the mobile phone?

any help please

NodeJS doesn’t run on the client. You can fallback to HTML5 websockets or Ajax calls to update data on your application.