Mattias Wolff
Mattias Wolff

Reputation: 907

Save tcp sessions in nodejs / redis?

I'm currently learning node.js by developing a small chat application over TCP (classic case).

What I would like to do now is to extend this application to use static users:

Current error message: TypeError: Object [object Object] has no method 'write'

This indicates that I cannot store a tcpSocket as I'm trying to do right now. Can someone tell me if I can make minor adjustments to make this right or should I rethinkt this solution?

Upvotes: 0

Views: 1364

Answers (2)

Mattias Wolff
Mattias Wolff

Reputation: 907

Since socket objects are to complex to store in Redis it seems like the way to go is to add identifier to the object according to link below.

This identifier could then of course be saved in a database to create realtions between different objects etc.

How to uniquely identify a socket with Node.js

Upvotes: 1

ilvar
ilvar

Reputation: 5841

Redis supports very few data types: string, lists, sets, sorted lists and hash tables. That's it. Some other types, like Date, can be easily converted to/from string, so it can be used too. But socket is a complex internal object, so you most probably can't convert it into string and therefore can't store in Redis.

Upvotes: 2

Related Questions