ilcato / homebridge-blynk

Homebridge plugin for the Blynk platform
MIT License
20 stars 30 forks source link

Homebridge crash #10

Closed fisero closed 6 years ago

fisero commented 7 years ago

After some time (1-3minutes) a homebridge crash with error output:

/usr/local/lib/node_modules/homebridge-blynk/index.js:227                                                                                           
          console.log('Status:', response.statusCode);                                                                                              
                                         ^                                                                                                          

TypeError: Cannot read property 'statusCode' of undefined                                                                                           
    at Request._callback (/usr/local/lib/node_modules/homebridge-blynk/index.js:227:35)                                                             
    at self.callback (/usr/local/lib/node_modules/homebridge-blynk/node_modules/request/request.js:186:22)                                          
    at emitOne (events.js:96:13)                                                                                                                    
    at Request.emit (events.js:188:7)                                                                                                               
    at Request.onRequestError (/usr/local/lib/node_modules/homebridge-blynk/node_modules/request/request.js:845:8)                                  
    at emitOne (events.js:96:13)                                                                                                                    
    at ClientRequest.emit (events.js:188:7)                                                                                                         
    at TLSSocket.socketOnEnd (_http_client.js:345:9)                                                                                                
    at emitNone (events.js:91:20)                                                                                                                   
    at TLSSocket.emit (events.js:185:7)

I have local blynk server running - temperatures are reported by script and read in mobile app. I have configuration in config.json:

{                                                                                                                                                   
        "bridge": {                                                                                                                                 
                "name": "Homebridge",                                                                                                               
                "username": "USER_NAME(MAC)",                                                                                                    
                "port": 51826,                                                                                                                      
                "pin": "131-35-174" },                                                                                                              

        "description": "This is an example configuration file. You can use this as a template for creating your own configuration file.",           

        "platforms": [                                                                                                                              
               {       "platform": "Blynk",                                                                                                        
                       "name": "Blynk",                                                                                                            
                       "server": "127.0.0.1",                                                                                                      
                       "httpsPort": "8443",                                                                                                        
                       "token": "MY_TOKEN",                                                                                
                       "dashboardName": "Temps",                                                                                                   
                       "accessories": [                                                                                                            
                               { "name": "t_out", "widget": "TemperatureSensor", "caption": "Temperature outside", "pin": "V0" },                  
                               { "name": "t_in", "widget": "TemperatureSensor", "caption": "Temperature inside", "pin": "V1" },                    
                               { "name": "t_up", "widget": "TemperatureSensor", "caption": "Temperature incoming", "pin": "V2" },                  
                               { "name": "t_down", "widget": "TemperatureSensor", "caption": "Temperature heater", "pin": "V3" }                   
                       ]                                                                                                                           
               }                                                                                                                                   
        ],                                                                                                                                          
        "accessories": [                                                                                                                            
        ]                                                                                                                                           
} 

Raspberry Pi B; Raspbian Jessie; Node v7.2.1, homebridge 0.4.10; homebridge-blynk 0.3.0

doom369 commented 7 years ago

I made quick fix. You can take changes from proposed pull request.

fisero commented 7 years ago

THX for quick response!

Error message after changes:

Error during performing request :  { Error: socket hang up                                                                                          
    at createHangUpError (_http_client.js:253:15)                                                                                                   
    at TLSSocket.socketOnEnd (_http_client.js:345:23)                                                                                               
    at emitNone (events.js:91:20)                                                                                                                   
    at TLSSocket.emit (events.js:185:7)                                                                                                             
    at endReadableNT (_stream_readable.js:974:12)                                                                                                   
    at _combinedTickCallback (internal/process/next_tick.js:74:11)                                                                                  
    at process._tickCallback (internal/process/next_tick.js:98:9) code: 'ECONNRESET' }                                                              
doom369 commented 7 years ago

Do you constantly get this error? Does script stop work after it?

fisero commented 7 years ago

After 30 minutes only 4 errors. All of them from the first 10 minutes after start and script is still running. Blynk server version 0.20.1

edit: All 4 errors appear at one moment.

doom369 commented 7 years ago

Ok. This is some kind of network error. There are of bunch of possible reasons. For now it is hard to give answer why this is happening.

fisero commented 7 years ago

That's ok. I just want help to make code more robustness. Thank You for support!

i3creations commented 7 years ago

Had the same issue. Turned out that I entered the wrong IP address of my Blynk server. DOH!