c# - Connecting to .NET webservice from android application -


i trying connect android application .net webservice. using github.com/signalr/java-client. have no experience android , cannot find solution problem. tried use these sample: github.com/signalr/java-samples implementing android client. in mainactivity.java have method

public void buttonclick(view v)     {         hubconnection conn = new hubconnection("http://192.168.132.28:9000");          // create hub proxy         hubproxy proxy = conn.createhubproxy("hubclient");          proxy.subscribe(new object() {             @suppresswarnings("unused")             public void messagereceived(string name, string message) {                 system.out.println(name + ": " + message);             }         });          // subscribe error event         conn.error(new errorcallback() {              @override             public void onerror(throwable error) {                 error.printstacktrace();             }         });          // subscribe connected event         conn.connected(new runnable() {              @override             public void run() {                 system.out.println("connected");             }         });          // subscribe closed event         conn.closed(new runnable() {              @override             public void run() {                 system.out.println("disconnected");             }         });          // start connection         conn.start()                 .done(new action<void>() {                      @override                     public void run(void obj) throws exception {                         system.out.println("done connecting!");                     }                 });          // subscribe received event         conn.received(new messagereceivedhandler() {              @override             public void onmessagereceived(jsonelement json) {                 system.out.println("raw received message: " + json.tostring());             }         });          // read lines , send them messages.         scanner inputreader = new scanner(system.in);          string line = inputreader.nextline();         while (!"exit".equals(line)) {             proxy.invoke("send", "console", line).done(new action<void>() {                  @override                 public void run(void obj) throws exception {                     system.out.println("sent!");                 }             });              line = inputreader.next();         }          inputreader.close();          conn.stop();     } 

this method invoked when button pressed. when press button exception microsoft.aspnet.signalr.client.transport.negotiationexception: there problem in negotiation server use this webservice testing. here full log logcat (after pressing button). disabled firewall testing. tried connect server on local computer , later on remote server. in both cases have same exception. appreciate suggestions. startup class in webservice:

using microsoft.aspnet.signalr; using microsoft.owin; using owin; using webapplication.features.authorization; using webapplication.features.samplepersistentconnection;  [assembly: owinstartupattribute(typeof(webapplication.startup))] namespace webapplication {     public partial class startup     {         public void configuration(iappbuilder app)         {             configureauth(app);             app.mapsignalr();             app.mapsignalr<demopersistentconnection>("/connections/demopersistentconnection");             app.mapsignalr<authorizationpersistentconnection>("/connections/authorizationpersistentconnection");              app.map("/enabledetailederrors", map =>             {                 var hubconfiguration = new hubconfiguration                 {                     enabledetailederrors = true                 };                  map.mapsignalr(hubconfiguration);             });         }     } } 

this demohub class:

using system; using system.threading.tasks; using microsoft.aspnet.signalr;  namespace webapplication.features.samplehub {     public class demohub : hub     {         public override task onconnected()         {             return clients.all.hubmessage("onconnected " + context.connectionid);         }          //public override task ondisconnected()         //{         //    return clients.all.hubmessage("ondisconnected " + context.connectionid);         //}          public override task onreconnected()         {             return clients.caller.hubmessage("onreconnected");         }          public void sendtome(string value)         {             clients.caller.hubmessage(value);         }          public void sendtoconnectionid(string connectionid, string value)         {             clients.client(connectionid).hubmessage(value);         }          public void sendtoall(string value)         {             clients.all.hubmessage(value);         }          public void sendtogroup(string groupname, string value)         {             clients.group(groupname).hubmessage(value);         }          public void joingroup(string groupname, string connectionid)         {             if (string.isnullorempty(connectionid))             {                 connectionid = context.connectionid;                 }              groups.add(connectionid, groupname);             clients.all.hubmessage(connectionid + " joined group " + groupname);         }          public void leavegroup(string groupname, string connectionid)         {             if (string.isnullorempty(connectionid))             {                 connectionid = context.connectionid;             }              groups.remove(connectionid, groupname);             clients.all.hubmessage(connectionid + " left group " + groupname);         }          public void incrementclientvariable()         {             clients.caller.counter = clients.caller.counter + 1;             clients.caller.hubmessage("incremented counter " + clients.caller.counter);         }          public void throwonvoidmethod()         {             throw new invalidoperationexception("throwonvoidmethod");         }          public async task throwontaskmethod()         {             await task.delay(timespan.fromseconds(1));             throw new invalidoperationexception("throwontaskmethod");         }          public void throwhubexception()         {             throw new hubexception("throwhubexception", new { detail = "i can provide additional error information here!" });         }          public void startbackgroundthread()         {             backgroundthread.enabled = true;             backgroundthread.sendonpersistentconnection();             backgroundthread.sendonhub();         }          public void stopbackgroundthread()         {             backgroundthread.enabled = false;                     }     } 

p.s. apologize not using https in links github, new users allowed create 2 links.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -