Socket.io Ionic

It’s working fine on my end and I just verified that those files are in the repo.

Try re-cloning it: http://github.com/beetz12/ionic2-web-chat

Hello! Thanks for your answer, now I think that I have everything installed and everything is correct. when I run ionic serve I can see in my terminal:

WARN: ionic.config.js has been deprecated, you can remove it.
WARN: No node_modules directory found, do you need to run npm install?
WARN: ionic.config.js has been deprecated, you can remove it.
Running live reload server: http://localhost:35729
Watching: www//*, !www/lib//*
√ Running dev server: http://localhost:8100
Ionic server commands, enter:
restart or r to restart the client app from the root
goto or g and a url to have the app navigate to the given url
consolelogs or c to enable/disable console log output
serverlogs or s to enable/disable server log output
quit or q to shutdown the server and exit

I have app running in localhost:8100 so… I have changed your files home.ts and chat-message.ts, the change has been localhost: 3000 - localhost: 8100 but localhost: 8100 I can’t see anything in my navigator. Do you know what I’m doing wrong?

When you open your browser dev tools, do you see any errors?

If you get a blank page, you are most likely missing the node modules.

You can install them by running

$ npm install

Yes, I have the following errors:

And I think that it’s not for “npm install” because with others proyect I don’t have problems. Do you know what can be happend?

If you get that warning, you don’t have all the libraries installed.

I have a quick question before I dive into the code. In this example, if user1 closes the app. what happens when the user2 sends a chat message? How/when is that message delivered to user1?

Hey,

When trying to use socket.io,i am getting the error"Cannot find the name SocketService" although I have included import {SocketService} from ‘…/…/providers/socket-service/socket-service’;

Is there any configuration that needs to be done apart from the ones mentioned in the blog?npm install socket.io-client --save

Please let me know

Vishnusr, i had the same problem, was just wrong path, at my app i was with folder

import {SocketService} from ‘…/…/providers/socket-service/socket-service’;

import {SocketService} from ‘…/…/providers/socket-service’;

Hi there, i have some issues using socket.io in Ionic2.hope you can help
i ran through your step…solved some problem…now im stuck with an error which is

Error: Cannot find module "component-emitter"
at webpackMissingModule (http://localhost:8100/build/main.js:116802:79)
at Object.module.exports (http://localhost:8100/build/main.js:116802:174)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:116592:14)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:57894:75)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:57973:73)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object.module.exports.createDebug.debug.createDebug.default (http://localhost:8100/build/main.js:106265:75)

have you ever encounter this problem??any solution for it???

i have solved this issue…:grin:

I’m working on a chat application with the Ionic front end, NodeJS backend and Socket.io for the socket.

Ionic App - https://github.com/mojofit/imojo

NodeJS Backend - https://github.com/mojofit/node-mojo

It’s in active development phase but basic interaction is ready if you are interested.

Here are some images

@ankushagg93
hi, if i want to add chat function in mobile web app, should i use socket.io or angular2-websocket?

thanks

como solucionar este errorimage

Here’s a way to get socket.io working in a typed manner (rather than with a socket: any).

Install these packages as dependencies:
"@types/socket.io-client": “^1.4.29”,
“socket.io-client”: “^2.0.1”,
Socket.io-client is the client side JS library.
@types/socket.io-client is the Typescript definition to use the corresponding Javascript library with Typescript.

Do these imports:
import io from ‘socket.io-client’;
There might be a better way to do these imports…

Use the socket like this:
let socket = io(“http://localhost:3000”);
socket.on(‘connection’, () => {
console.log(‘socket is connected!’);
});
socket.emit(‘event’, () => {
console.log(‘some event happened’);
});

2 Likes

I new to Ionic,
May i know how to run this application.
Installed requirements on my PC node.js,Ionic-Cordova.

Is this example for Mobile or Web.
Thank you.