stephen-moyer / ngx-signalr-hubservice

Makes using SignalR in Angular 2/4 easy
MIT License
24 stars 5 forks source link

connect(url) issues #1

Closed zhangboli51 closed 7 years ago

zhangboli51 commented 7 years ago

SO this is the error referring from : this.connected = await this.hubService.connect(url).toPromise();

and URL refer to const url = 'http://localhost:4200/signalr';

and the following is error from compiler.

ERROR in C:/Users/bgm3325/Desktop/easystart/irm-pro/src/app/app.component.ts (63,52): Argument of type '"http://localhost:4200/signalr"' is not assignable to parameter of type 'boolean'.

stephen-moyer commented 7 years ago

Whoops, looks like last version I accidentally removed that.

I will update in a few minutes and let you know when to install latest.

stephen-moyer commented 7 years ago

Fixed. Install latest npm install ngx-signalr-hubservice@latest --save and you should be good to go. LMK if it works.

zhangboli51 commented 7 years ago

Thank you for your quick reply. but another issue come out. my webpage stuck at "connecting to the chat"

chrome console give me this error

vendor.bundle.js:46364 ERROR Error: Uncaught (in promise): ReferenceError: $ is not defined
ReferenceError: $ is not defined
    at HubService.webpackJsonp.../../../../ngx-signalr-hubservice/ngx-signalr-hubservice.js.HubService.initConnection (vendor.bundle.js:2845)
    at HubService.webpackJsonp.../../../../ngx-signalr-hubservice/ngx-signalr-hubservice.js.HubService._connect (vendor.bundle.js:2885)
    at HubService.webpackJsonp.../../../../ngx-signalr-hubservice/ngx-signalr-hubservice.js.HubService.connect (vendor.bundle.js:2876)
    at AppComponent.<anonymous> (main.bundle.js:119)
    at step (main.bundle.js:90)
    at Object.next (main.bundle.js:71)
    at main.bundle.js:65
    at new ZoneAwarePromise (polyfills.bundle.js:3262)
    at webpackJsonp.../../../../../src/app/app.component.ts.__awaiter (main.bundle.js:61)
    at AppComponent.webpackJsonp.../../../../../src/app/app.component.ts.AppComponent.ngOnInit (main.bundle.js:112)
    at HubService.webpackJsonp.../../../../ngx-signalr-hubservice/ngx-signalr-hubservice.js.HubService.initConnection (vendor.bundle.js:2845)
    at HubService.webpackJsonp.../../../../ngx-signalr-hubservice/ngx-signalr-hubservice.js.HubService._connect (vendor.bundle.js:2885)
    at HubService.webpackJsonp.../../../../ngx-signalr-hubservice/ngx-signalr-hubservice.js.HubService.connect (vendor.bundle.js:2876)
    at AppComponent.<anonymous> (main.bundle.js:119)
    at step (main.bundle.js:90)
    at Object.next (main.bundle.js:71)
    at main.bundle.js:65
    at new ZoneAwarePromise (polyfills.bundle.js:3262)
    at webpackJsonp.../../../../../src/app/app.component.ts.__awaiter (main.bundle.js:61)
    at AppComponent.webpackJsonp.../../../../../src/app/app.component.ts.AppComponent.ngOnInit (main.bundle.js:112)
    at resolvePromise (polyfills.bundle.js:3198)
    at new ZoneAwarePromise (polyfills.bundle.js:3265)
    at webpackJsonp.../../../../../src/app/app.component.ts.__awaiter (main.bundle.js:61)
    at AppComponent.webpackJsonp.../../../../../src/app/app.component.ts.AppComponent.ngOnInit (main.bundle.js:112)
    at checkAndUpdateDirectiveInline (vendor.bundle.js:56180)
    at checkAndUpdateNodeInline (vendor.bundle.js:57676)
    at checkAndUpdateNode (vendor.bundle.js:57615)
    at debugCheckAndUpdateNode (vendor.bundle.js:58476)
    at debugCheckDirectivesFn (vendor.bundle.js:58417)
    at Object.eval [as updateDirectives] (ng:///AppModule/AppComponent_Host.ngfactory.js:8)
stephen-moyer commented 7 years ago

You have to include jQuery in your index.html for signalr to work.

zhangboli51 commented 7 years ago

Just simply add this <script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.2.1.min.js"></script> to my index.html , but it doesn't work.

stephen-moyer commented 7 years ago

testsignalr.zip Try this test project I use. It should work.

zhangboli51 commented 7 years ago

webpage shows :

Error connecting to the chat!

chrome console error

:64339/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&_=1501623826149 Failed to load resource: net::ERR_CONNECTION_REFUSED

zhangboli51 commented 7 years ago

https://www.dropbox.com/s/3d40t54qe1xhd7m/easystart.zip?dl=0 This is my files . no clue what's wrong with my code.

stephen-moyer commented 7 years ago

Are you sure you have an asp.net signalr server running? You need to change the port the app is trying to connect to.

stephen-moyer commented 7 years ago

You need to change the url you're using for your signalr server.

On Aug 1, 2017, 17:46, at 17:46, zhangboli51 notifications@github.com wrote:

webpage shows :

Error connecting to the chat!

chrome console error

:64339/signalr/negotiate?clientProtocol=1.5&connectionData=%5B%7B%22name%22%3A%22chathub%22%7D%5D&_=1501623826149 Failed to load resource: net::ERR_CONNECTION_REFUSED

-- You are receiving this because you were assigned. Reply to this email directly or view it on GitHub: https://github.com/steveadoo32/ngx-signalr-hubservice/issues/1#issuecomment-319506616

stephen-moyer commented 7 years ago

Closing. This issue was fixed.