question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi, I have in my app.modules.ts this: const config: SocketIoConfig = { url: ${environment.host}, options: {} }; … imports: [ … SocketIoModule.forRoot(config) ],

My socket.io be connected at bootstrap. Can I connect socket manually ? Tnx

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

45reactions
seba-salavillacommented, Apr 4, 2019

Hi, I have in my app.modules.ts this: const config: SocketIoConfig = { url: ${environment.host}, options: {} }; … imports: [ … SocketIoModule.forRoot(config) ],

My socket.io be connected at bootstrap. Can I connect socket manually ? Tnx

Yes you can, first add option autoConnect : false const config: SocketIoConfig = { url: ${environment.host}, options: { autoConnect : false } };

then, in Socketservices.ts create a method Connect() with params as you want. Now you can call the method and reconfigure the connections and options of socket instance.

Example:

Connect(options){
    this.socket.ioSocket.io.opts.query = { token: 'minuevotoken' } //new options
    this.socket.ioSocket.io.uri = "http://localhost:3001" //new uri
    this.socket.connect(); //manually connection
}
5reactions
nihalmpatelcommented, Jan 23, 2019

@feof The socket connection automatically establishes at bootstrap because of the configuration in App module. If you want to connect socket manually, a workaround could be to disconnect socket connection (this.socket.disconnect()) at bootstrap and connect (this.socket.connect()) again whenever it’s needed.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Manual Connection Steps - Computing Services
Windows Manual Connection Steps. Follow the steps below to manually connect to the CMU-SECURE network. Step 1: Remove the Existing Wi-Fi Profile.
Read more >
Windows 10 - How to Manually Connect to a Wi-Fi Network
1. From the Windows desktop, navigate: Start Settings iconWi-Fi. 2. From the Related settings section, select Network and Sharing Center. 3. Select Set...
Read more >
connect(2) - Linux manual page - man7.org
CONNECT(2) Linux Programmer's Manual CONNECT(2) ... The connect() system call connects the socket referred to by the file descriptor sockfd to the address ......
Read more >
How to set up a manual connection on Windows using ...
How to set up a manual connection on Windows using OpenVPN · Download the OpenVPN GUI application. · Open the installation file and...
Read more >
Connect Care Manual
This online manual gathers tips, guides, resources and norms for prescribers who use the Connect Care clinical information system (CIS).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found