Chat with nodejs and mysql

Asked

Viewed 250 times

1

I created a chat with nodejs and Mysql to search for information from user... but I have a following problem: when the connection drops or restart the server nodejs, do not go back logging user and password. Someone has a tip on how to do this that when falling he comes back logging?

OBS: I managed to make him access Mysql and enter the room... only when the nick becomes as NULL he is unable to find this data when he returns. Someone has a suggestion?

  • is using the socket io. ?

  • @Sneepsninja, yes I am

  • Yes staff no more and the server reconect and yes chat password user... they get lost already tried localstorage localsession

  • I will vote on your question because I have seen that more people are starting with Ode and this will help everyone who is starting :)

  • @Sneepsninja , vlw then I will organize and make it clear to the staff :D

  • Then you put yourself an answer to how you solved and accept it to close the matter straight

Show 1 more comment

1 answer

0

pass so reconect parameter:

io.connect(                                                             // CRIVAR UM SOCKET
            $("#socket").val(),{                                            // ENDERECO DO SOCKET
            'reconnect': true                                               // que irá informar se o socket irá tentar se conectar caso perca a conexão com o Server.
           ,'reconnection delay': 500                                       // informa o tempo em milissegundos que será o delay da tentativa de conexão.
           ,'max reconnection attempts': 1000                               // informa o valor máximo de tentativas de conexão com o Server.
           ,'secure': false                                                 // informando se a conexão com o Server irá utilizar criptografia (conexões HTTPS).
    });
  • Yes staff no more and the server reconect and yes chat password user... they get lost already tried localstorage localsession

  • chat user and password you are storing where?

  • so I couldn’t find a place in the html to save, that he can recur

  • @Willian has already thought about session cookies?

  • @Guilhermenascimento, then by the navigator?

  • @Willian session cookies are something from HTTP and do not necessarily need a browser, as you mentioned html, I imagined that either a web page or a webapp, in both it is possible to implement "session cookies" that are different from "normal cookies".

  • I’m on the outside of Ode.js, but I believe you could use the var express = require('express'); ... express.cookieParser @Willian - the Sneepsninja seems to have dominion, I believe soon he will indicate something in this sense

  • @Willian the connection with Mysql is done with Node-mysql or you make an ajax in php, has a link here that the guy uses a pool to cache the connections ve se resolve https://codeforgeek.com/2015/01/nodejs-mysql-tutorial/

  • @Sneepsninja type this connection I do the problem and if the internet falls or the nodejs fall... it does not come back with the user and password... I wanted to return identified user as if nothing had happened... the chat already comes back to the identified user

  • @Willian then I think you will have to use Session, I implemented my Node with ajax and php, but pure Node as you are using I didn’t get to use... has another link here that teaches to use Session on Node https://codeforgeek.com/2014/09/manage-session-using-node-js-express-4/

  • Yes, that’s what this Session vlwww :D business was all about

  • @Sneepsninja and about that you know: actually to using pure pq axo that is the only way... what I really wanted was to develop everything in php and angular and use Node only in the part to send msg and identify the user for the chat that uses db mysql... because the fuck that when running Node app.js he ends up generating a site has got How can I not use this site? do everything on apache server? user Can only chat and notifications would be too top

  • I opened a chat if I wanted something more, but I will try to encourage you to create new questions so that the whole community gets them too.. follow http://chat.stackexchange.com/rooms/25423/nodejs

Show 8 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.