Redis and Unity 5 (C#)

626 views
Skip to first unread message

dreami...@gmail.com

unread,
Feb 26, 2017, 11:07:42 PM2/26/17
to Redis DB
Hi, can i connect redis and unity directly?  I was able to use pubsub between redis and unity c# but when i tried to test it on mobile, it gave me an socket error. I connected them remotely and we are developing an android app and my boss asked me to use redis for chat system of the app. Do i need to use node.js and socket.io to be able to use it on mobile?

AlexanderB

unread,
Mar 2, 2017, 6:06:28 PM3/2/17
to Redis DB
I haven't poked around with the very latest version of unity, but in general the c# system.net libraries don't work on mobile. Instead on mobile if you want socket level access you need to build things onto of unity's transport layer stuff. See: https://docs.unity3d.com/Manual/UNetUsingTransport.html

That being said, Redis is not really built to have clients talk to it directly. In particular it doesn't have the security features you'd need. 

You'll likely want to build a simple chat server on the backend using something like node.js or socket.io. Your clients would open up a socket communication with that server, and that server would in turn be the one talking to redis. 

This looks like a great blog post of someone building something just like this. 


You'd build something very similar on the backend, but rather than having a webpage to your backend using javascript over sockets, you'd write something in unity that does the socket communication. I'm not sure if this library is still up to date or works on mobile, but it might work out of the box https://www.assetstore.unity3d.com/en/#!/content/21721 if you want to stick with socket.io style sockets. 

dreami...@gmail.com

unread,
Mar 3, 2017, 1:38:29 AM3/3/17
to Redis DB
Thank you for your reply Alexander. I'm now studying node js and socket io and how to use redis with them. I'm just having a hard time on how to implement redis on node js because im a php guy. Thank you for your suggestions.

jose

unread,
Mar 3, 2017, 7:42:49 AM3/3/17
to redi...@googlegroups.com
sockets are already enabled on android in unity 4 pro and unity 5.x

--
You received this message because you are subscribed to the Google Groups "Redis DB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+unsubscribe@googlegroups.com.
To post to this group, send email to redi...@googlegroups.com.
Visit this group at https://groups.google.com/group/redis-db.
For more options, visit https://groups.google.com/d/optout.

CharSyam

unread,
Mar 3, 2017, 7:52:38 AM3/3/17
to redi...@googlegroups.com
I strongly recommend never connect redis and your app directly.

2017년 3월 3일 금요일, jose<jos...@gmail.com>님이 작성한 메시지:

dreami...@gmail.com

unread,
Mar 5, 2017, 10:54:24 PM3/5/17
to Redis DB
thank you for your reply. I'm still studying on node js and socket io, i am not yet able to test it on android mobile. but thanks.
To unsubscribe from this group and stop receiving emails from it, send an email to redis-db+u...@googlegroups.com.

dreami...@gmail.com

unread,
Mar 6, 2017, 12:34:50 AM3/6/17
to Redis DB
yea, that's what i realize since it lags also when i tried it on unity editor directly connecting to redis. i'll appreciate if you can post or give me a link tutorial on said topic. thanks
Reply all
Reply to author
Forward
0 new messages