Search Unity

Best HTTP Released

Discussion in 'Assets and Asset Store' started by BestHTTP, Sep 11, 2013.

  1. exoter

    exoter

    Joined:
    Apr 25, 2015
    Posts:
    7
    Yes, I even reimported the plugin from the asset store. Here is a video - as you can see the editor is stopped in the background but I keep receiving messages: https://www.screencast.com/t/ihqmb9ys4
     
  2. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    47
    First of all, thanks for a great asset.

    I had been convinced to head towards SignalR Core. And then realised that, even under 2018.1, SignalR was still a bit of a pain to get working.

    I’m going to try your WebSocket workaround today, but is there an estimated update to BestHTTP that supports SignalR Core?

    Thanks!
     
  3. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @VOTRUBEC

    By now I have a working version for SignalR Core 1.0.0-alpha2. But, because they are still changing the protocol i can't release it yet or do further work on it (like adding examples).
    However, I can send it to you if you want, it might be easier to find out how it works than implement the protocol yourself. Or at least I hope so... :)
     
  4. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    when we try to use namespaces we always get an error Object reference not set to an instance of an object:
    we try:
    Socket nsp = manager["/customNamespace"];
    and
    Socket nsp = manager.GetSocket("/customNamespace");
    and
    MySocketManager.instance.SetNamespaceForSocket ("/customNamespace");
    can you give us a example of usage? thanks!
     
  5. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @devjand

    manger["/namespace"] will call GetSocket("/namespace") so they are equivalent. GetSocket will always return with a Socket object, so one thing that i can think of is that maybe manager is null?

    An example would be the same as you are trying to use. These are in use in one of my test code:
    Code (CSharp):
    1. Manager.GetSocket("/nsp").On(SocketIOEventTypes.Connect, (socket, packet, arg) =>
    2. {
    3.     Debug.LogWarning("Connected to /nsp");
    4.  
    5.     socket.Emit("testmsg", "Message from /nsp 'on connect'");
    6. });
    7.  
    8.  
    9. Manager.GetSocket("/nsp").On("nsp_message", (socket, packet, arg) =>
    10. {
    11.     Debug.LogWarning("nsp_message: " + arg[0]);
    12. });
     
  6. bdominguezvw

    bdominguezvw

    Joined:
    Dec 4, 2013
    Posts:
    92
    @BestHTTP could you send us the last version that worked with Unity 4.7.2 (I suppose that the version that is on the Asset Store will not work)? We have an old project that we can't upgrade and we have problems with Unity's WWW class on macOS. We think that it's because of newer certificates or something like that (our connection is through HTTPS) so we want to try with your asset.

    Tell me where yo send our invoice number.

    Thanks.
     
  7. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    thanks, and other question, why there are no one example of simple client and server-side code?
    you only give the client side in all the examples, and the examples are too large.
    A simple and separate example of send and recieve one value whit client and server was perfect!
     
  8. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @bdominguezvw

    Sent some download links that you can try out.
     
  9. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
  10. bdominguezvw

    bdominguezvw

    Joined:
    Dec 4, 2013
    Posts:
    92
    Thanks! I'm going to try it out and I will post the results.
     
  11. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    sorry because im noob whit sockets, but i dont understand:
    whit:
    Manager.Open();
    or putting:
    options.AutoConnect = true;
    you connect, isn it?

    but you define the namespace in the socket:
    Socket = Manager["/valve-nsp"];
    Then, socket no connetc, is manager, and to manager you cant define namespace...
    I dont understand, sorry...
     
  12. VOTRUBEC

    VOTRUBEC

    Joined:
    Dec 17, 2014
    Posts:
    47
    A working version for alpha2? Perfect! That's what I'd be working against anyway, with full knowledge it's likely to change before the final release. And, just for you peace of mind, I've got the Pro version of BestHTTP... :)
     
  13. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
  14. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @devjand

    If AutoConnect set to True, the Manager will start to connect when you first access a socket (first GetSocket("...") or Manager["..."] call) and no Manager.Open() is necessary.
    When AutoConnect is set to False, you have to call Manager.Open().

    Also, when you access a new namespace it will start to connect to that namespace too (it will send a connect packet to the server), but can use that socket right away. Like you can subscribe to events, or send events to the server.

    Socket.IO rooms: rooms are implemented purely in the server. The client doesn't know about them.
     
  15. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    I show here the code of my server, also the code of a client made in javascript that works and connects with the server and finally the client code made in unity with the BestHttp that I can not connect to the server using the mamescpace and that is the only real importan here!!
    Why it dont work??? :S
    Cheers and thanks for your fast answers man.

    server.js

    Code (JavaScript):
    1. var port = process.env.PORT || 3000;
    2. var io = require('socket.io')(port);
    3. var shortId = require('shortid');
    4. const valveNSP = io.of('/valve-nsp');
    5.  
    6. var players = [];
    7.  
    8. console.log("server started on port " + port);
    9.  
    10.  
    11. valveNSP.on('connection', function (socket) {
    12.    
    13.     var thisPlayerId = shortId.generate();
    14.     var player = {
    15.         id:thisPlayerId
    16.     };
    17.     players[thisPlayerId] = player;
    18.    
    19.     console.log("client connected, id = ", thisPlayerId);  
    20.     socket.emit('register', {id:thisPlayerId});
    21.    
    22.     socket.on('disconnect', function () {
    23.         console.log('client disconected');
    24.         delete players[thisPlayerId];
    25.         socket.broadcast.emit('disconnected', { id: thisPlayerId });
    26.     });
    27.     valveNSP.on('botonTest', function (data) {
    28.         console.log('boton pulsado, valor: ' +data.var1+ " id: " + thisPlayerId);
    29.         //socket.broadcast.emit('botonPulsadoE', data);
    30.     });
    31.     socket.on('slider', function (data) {
    32.         console.log('Slider Movido: ' + data.valorSlider);
    33.         socket.broadcast.emit('sliderMovidoE', data);
    34.     });
    35. });
    javascript-client.js

    Code (JavaScript):
    1. //@ts-check
    2. const io = require('socket.io-client');
    3. var socket = io.connect('http://localhost:3000/valve-nsp', { 'forceNew': true, query: "item=valve" }); // CONECTA A SOCKET COMO VÁLVULA
    4.  
    5. socket.on('connect', function () {  // EVENTO DE CONEXIÓN
    6.     console.log("Estoy conectado al servidor como válvula.");
    7. });
    8.  
    9. socket.on('roomID', function (id) { // CUANDO SE TIENE UNA ID PARA LA VÁLVULA SE RECIBE ESTE EVENTO
    10.     console.log("Muestro en aplicación de válvula la ID: " + id + " para conectar con SCADA.")
    11. });
    12.  
    13. socket.on('SCADA-CON', function (id) {  // CUANDO SE CONECTA UN SCADA SE RECIBE ESTE EVENTO
    14.     console.log("Se ha conectado un cliente al SCADA con la ID: " + id)
    15. });
    16.  
    17. socket.on('SCADA-DESC', function (id) { // CUANDO SE DESCONECTA UN SCADA SE RECIBE ESTE EVENTO
    18.     console.log("Se ha desconectado un cliente con ID " + id + " del SCADA.")
    19. });
    20.  
    21. socket.on('disconnect', function (reason) { // CUANDO SE DESCONECTA LA APLICACIÓN DE LA VÁLVULA SE DISPARA ESTE EVENTO
    22.     console.log("Desconectado. Razón: " + reason);
    23. });
    24.  
    25. // ENVÍA DATOS ALEATORIOS CADA 2 SEGUNDOS -> TEMPERATURA Y PRESIÓN
    26. setInterval(emitRandom, 2000);
    27. function emitRandom() {
    28.     socket.emit("dataToServer", { temp: Math.round(Math.random().toFixed(2) * 100), pres: Math.round(Math.random().toFixed(2) * 10) });
    29. }
    csharp-unity-client.cs

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3.  
    4. using UnityEngine;
    5. using BestHTTP.SocketIO;
    6.  
    7. public class PruebaSimple : MonoBehaviour {
    8.  
    9.     private SocketManager Manager;
    10.     Socket Socketillo;
    11.  
    12.     void Start () {
    13.        
    14.         SocketOptions options = new SocketOptions();
    15.         options.AutoConnect = true;
    16.  
    17.         Manager = new SocketManager(new Uri("http://localhost:3000/socket.io/"), options);
    18.         //Socketillo = Manager.Socket;
    19.         //Socketillo = Manager.GetSocket("/valve-nsp");
    20.         Socketillo = Manager["/valve-nsp"];
    21.  
    22.         // The argument will be an Error object.
    23.         Socketillo.On(SocketIOEventTypes.Error, (socket, packet, args) => Debug.LogError(string.Format("Error: {0}", args[0].ToString())));
    24.         //Manager.Open();
    25.     }
    26.     public void EnviaTest()
    27.     {
    28.         Dictionary<string, object> gameActionData = new Dictionary<string, object>();
    29.         gameActionData.Add("var1", 33);
    30.         gameActionData.Add("var2", 44);
    31.         gameActionData.Add("var3", "hola");
    32.  
    33.         Socketillo.Emit("botonTest", gameActionData);      
    34.     }
    35. }
    36.  
     
  16. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @devjand

    This code worked:
    Code (CSharp):
    1. void Test()
    2. {
    3.     SocketOptions options = new SocketOptions();
    4.     options.AutoConnect = false;
    5.  
    6.     SocketManager manager = new SocketManager(new Uri("http://localhost:1337/socket.io/"), options);
    7.     Socket socket = manager.GetSocket("/valve-nsp");
    8.  
    9.     socket.On("register", OnRegister);
    10.  
    11.     manager.Open();
    12. }
    13.  
    14. private void OnRegister(Socket socket, Packet packet, object[] args)
    15. {
    16.     Debug.Log("OnRegister " + (args[0] as Dictionary<string, object>)["id"].ToString());
    17.  
    18.     EnviaTest(socket);
    19. }
    20.  
    21. public void EnviaTest(Socket socketillo)
    22. {
    23.     Dictionary<string, object> gameActionData = new Dictionary<string, object>();
    24.     gameActionData.Add("var1", 33);
    25.     gameActionData.Add("var2", 44);
    26.     gameActionData.Add("var3", "hola");
    27.  
    28.     socketillo.Emit("botonTest", gameActionData);
    29. }
    With the following server:
    Code (JavaScript):
    1. var port = process.env.PORT || 3000;
    2. var io = require('socket.io')(port);
    3. var shortId = require('shortid');
    4. const valveNSP = io.of('/valve-nsp');
    5.  
    6. var players = [];
    7.  
    8. console.log("server started on port " + port);
    9.  
    10.  
    11. valveNSP.on('connection', function (socket) {
    12.  
    13.     var thisPlayerId = shortId.generate();
    14.     var player = {
    15.         id: thisPlayerId
    16.     };
    17.     players[thisPlayerId] = player;
    18.  
    19.     console.log("client connected, id = ", thisPlayerId);
    20.     socket.emit('register', { id: thisPlayerId });
    21.  
    22.     socket.on('disconnect', function () {
    23.         console.log('client disconected');
    24.         delete players[thisPlayerId];
    25.         socket.broadcast.emit('disconnected', { id: thisPlayerId });
    26.     });
    27.     socket.on('botonTest', function (data) {
    28.         console.log('boton pulsado, valor: ' + data.var1 + " id: " + thisPlayerId);
    29.         //socket.broadcast.emit('botonPulsadoE', data);
    30.     });
    31.     socket.on('slider', function (data) {
    32.         console.log('Slider Movido: ' + data.valorSlider);
    33.         socket.broadcast.emit('sliderMovidoE', data);
    34.     });
    35. });
    Only changed one line. From
    Code (JavaScript):
    1. valveNSP.on('botonTest', function (data) {
    to

    Code (JavaScript):
    1. socket.on('botonTest', function (data) {
     
  17. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @devjand

    And this was the output of the client and server:
    upload_2018-1-24_18-8-22.png
     
  18. asethi

    asethi

    Joined:
    Jul 24, 2012
    Posts:
    16
    I'm trying to upload a file via Best HTTP framework.
    I want the the result that this curl snippet produces:
    Code (CSharp):
    1. curl -X POST https://api.moltin.com/v2/files \
    2.     -H "Authorization: Bearer XXXX" \
    3.     -H "Content-Type: multipart/form-data" \
    4.     -F file=@/path/to/file \
    5.     -d public=1
    But using this framework in C# the file gets uploaded but the extension changes to ".dat" from ".txt" and filename is not automatically saved. Is there any otherway than using BinaryData method?
    Code (CSharp):
    1. string uri = "https://api.moltin.com/v2/files";
    2.             var request = new HTTPRequest(new Uri(uri), HTTPMethods.Post);
    3.             request.AddHeader("Authorization", authObj.token_type + " " + authObj.access_token);
    4.             request.AddHeader("Content-Type", "multipart/form-data");
    5.  
    6.             request.AddBinaryData("file", File.ReadAllBytes(@filePath));
    7.             request.AddField("public", "true");
    8.             request.Send();
    9.  
    10.             return request;
    How to add a "File" field in the request rather than "Body" field?
     
  19. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @asethi

    You can specify the extension in the third parameter:
    Code (CSharp):
    1. string uri = "https://api.moltin.com/v2/files";
    2. var request = new HTTPRequest(new Uri(uri), HTTPMethods.Post);
    3. request.AddHeader("Authorization", authObj.token_type + " " + authObj.access_token);
    4.  
    5. request.FormUsage = BestHTTP.Forms.HTTPFormUsage.Multipart;
    6.  
    7. request.AddBinaryData("file", File.ReadAllBytes(@filePath), Path.GetFileName(@filePath));
    8. request.AddField("public", "true");
    9.  
    10. request.Send();
    11.  
    12. return request;
    Also, setting the Content-Type has no effect in this case, as the plugin will overwrite it when AddField or AddBinaryData is used.
     
    asethi likes this.
  20. asethi

    asethi

    Joined:
    Jul 24, 2012
    Posts:
    16
    @BestHTTP Thanks a lot!
     
  21. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    Hi,

    We just updated our Unity from version 2017.1.1 to 2017.3.3p and now our Android app crashes, when closing the websocket connection.

    At the logs we can see the following error:

    Caused by: java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00002521
    Build fingerprint: 'OnePlus/OnePlus3/OnePlus3T:8.0.0/OPR6.170623.013/12041042:user/release-keys'
    Revision: '0'
    pid: 11309, tid: 12084, name: UnityMain >>> com.***.***<<<
    r0 00000000 r1 efa8bb80 r2 ca6d0000 r3 ca6d0000
    r4 00002521 r5 efa8bb80 r6 00002521 r7 bc6d47b0
    r8 00000001 r9 a49eca38 sl a854fbd0 fp badff698
    ip ca4946c4 sp badff688 lr c8285f24 pc c92a5ea0 cpsr 0000004d

    at libil2cpp.il2cpp::vm::Object::IsInst(Il2CppObject*, Il2CppClass*)(vm:32)
    at libil2cpp.NetworkStream_Read_m89488240(NetworkStream_Read_m89488240:980)


    I also arranged a very simple project and the problem reproduced over there, do you want me to send it to you?
    Basically the simple project only contains your lib + code which connects to some websocket server.
    Compiled with il2cpp.
    After the connection opened if you close the websocket, for example by closing your wifi, the app wll crash.

    Do you know this crash? Something that we can do?
     
  22. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
  23. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @tomerpeledNG

    Using the same setup (2017.3.3p, latest version of the plugin from the store, compiled with IL2CPP) i couldn't reproduce any crash.

    Crashes in NetworkStream.Read (libil2cpp.NetworkStream_Read_m89488240) should be reported to Unity, especially if it worked with previous version of Unity.
    Is it possible that you are using the 'Experimental (.NET 4.6 Equivalent)' Scripting Runtime?
     
  24. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    Thanks man, was a problem of version the namespaces issue.
    But now, with the last version, i have other problem:
    HTTPUpdateDelegator.cs
    is making all the time parallels conexions on editor (with no playmode on)
    Cheers!
     
  25. tomerpeledNG

    tomerpeledNG

    Joined:
    Jul 14, 2017
    Posts:
    81
    @BestHTTP I've just sent you an email with the project and details.

    And yes we're are using the .Net 4.6 Runtime.
     
  26. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    besides the problem of HTTPUpdateDelegator.cs
    i have 2 questions:
    it is possible to send querys? like:
    var socket = io.connect('http://localhost:3000/valve-nsp', { 'forceNew': true, query: "item=valve" });
    from client, to recieve something like:
    var query = socket.handshake.query;
    if(query.item == 'valve') {......
    from server.
    And quesion 2:
    Is it possible to continue receiving data when one of the clients is not active or is minimized?
    Greetings and thanks for the great support!
     
  27. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @devjand

    The SocketOptions has an AdditionalQueryParams property that you can use like this:
    Code (CSharp):
    1. SocketOptions options = new SocketOptions();
    2. options.AutoConnect = false;
    3. options.AdditionalQueryParams = new PlatformSupport.Collections.ObjectModel.ObservableDictionary<string, string>();
    4. options.AdditionalQueryParams.Add("forceNew", "true");
    5. options.AdditionalQueryParams.Add("item", "value");
    For question 2: that's depends on the platform. Under mobile OSs, the system might close the underlying TCP connection when the application goes to the background.
     
  28. exoter

    exoter

    Joined:
    Apr 25, 2015
    Posts:
    7
    ping
     
  29. devjand

    devjand

    Joined:
    Nov 15, 2012
    Posts:
    15
    And what about the HTTPUpdateDelegator.cs problem?
    Is still making connections on editor.
     
  30. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
  31. pflamant

    pflamant

    Joined:
    Dec 7, 2017
    Posts:
    4
    @BestHTTP
    Hi,
    Thanks for your great work, this plugin seems awesome :)
    I have 3 questions:
    - Is the plugin still compatible with Hololens? (I'm interested in Server-Sent Events)
    - Is the plugin compatible with Unity 2017.3? (sorry for that question)
    - Can I buy the license one time and use it in multiple games? (I've read the license agreement but just wanted to be sure)

    Thank you very much,
    Pierre
     
  32. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @pflamant

    Hololens support: I don't own a device, so I can't officially support it, but i know about 4 or 5 clients who are using the plugin on Hololens devices without any issues. Server-Sent Events must work too.

    Unity 2017.3 compatibility: Yes, personally I use 2017.3 to do my development and tests with the plugin.

    License: Yes, you buy it once and you can use it many times. Also, you can download future updates though the Asset Store window in the Unity editor.
     
  33. RazaTech

    RazaTech

    Joined:
    Feb 27, 2015
    Posts:
    169
    Please Add support for Data response Mocking.
     
  34. silentmaster

    silentmaster

    Joined:
    Oct 2, 2013
    Posts:
    2
    We are getting "NullReferenceException: Object reference not set to an instance of an object" in live within BestHTTP 'SelectTransport' code... connecting to node socket.io server.

    The error stack is as follows...

    It seems to be only happening to some users in some rare cases...

    We do check if the socket is open before emitting the 'leave_room'. ('_client' is a 'SocketManager' instance)

    Code (CSharp):
    1.  
    2. if(!Util.IsNull(this._client) && this._client.Socket.IsOpen) {
    3.             Debug.Log("Leave Room: " + roomId.ToString());
    4.             this._client.Socket.Emit("leave_room", roomId);
    5.         }
    6.  
    Please give us some insight to why it could be happening?
     
  35. unity_surviver

    unity_surviver

    Joined:
    May 15, 2017
    Posts:
    4
    hello! we are using last ver of best http pro and after each scene play getting this error in editor: InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: HTTP Update Delegator. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script. >> it seems that HTTPUpdateDelegator script does some work in "OnDestroy" callback.
     
  36. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @RazaTech

    Thank you for the suggestion, added it to my TODO list.
     
    RazaTech likes this.
  37. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @silentmaster

    That's an interesting one. It can throw an exception only if the SocketManager's State is Open, but its Transport is set to null. However, Transport is will be set to null in the Close function, and and its State will be set to Closed there.

    Made a workaround that will prevent the nullref exception that will be released in the next update, and I will try to come up a way to reproduce it.
     
  38. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
  39. silentmaster

    silentmaster

    Joined:
    Oct 2, 2013
    Posts:
    2
    We just did a temp patch with the following in 'SelectTransport' code... haven't pushed to live yet... will see after our next app update.

    Code (CSharp):
    1.  
    2.             if (Transport == null)
    3.                 return null;
    4.  
     
  40. TailKitty

    TailKitty

    Joined:
    Nov 23, 2016
    Posts:
    6
    Hi,

    Had a problem with Build for Windows Universal after switching to Unity 2017.3.1f1

    UnityException: Failed to run serialization weaver with command "Temp\StagingArea\Data\Managed\BestHTTP.dll" "-pdb" "-verbose" "-unity-engine=Temp\StagingArea\Data\Managed\UnityEngine.CoreModule.dll" "Temp\StagingArea\TempSerializationWeaver" "-lock=UWP\project.lock.json" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Facade" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.CallsVoipContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.SocialInfo.SocialInfoContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.DevicesLowLevelContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.Printers.PrintersContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Graphics.Printing3D.Printing3DContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Networking.Connectivity.WwanContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Services.Store.StoreContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.Profile.ProfileHardwareTokenContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.Profile.ProfileSharedModeContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.UI.ViewManagement.ViewManagementViewScalingContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Activation.ActivatedEventsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Activation.ActivationCameraSettingsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Activation.ContactActivatedEventsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Activation.WebUISearchActivatedEventsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Background.BackgroundAlarmApplicationContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.Background.CallsBackgroundContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.LockScreenCallContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.FullTrustAppContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Preview.Notes.PreviewNotesContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Resources.Management.ResourceIndexerContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Search.Core.SearchCoreContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Search.SearchContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.StartupTaskContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Wallet.WalletContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.Custom.CustomDeviceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.Portable.PortableDeviceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.Printers.Extensions.ExtensionsContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.Scanners.ScannerDeviceContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.Sms.LegacySmsApiContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Gaming.Preview.GamesEnumerationContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Globalization.GlobalizationJapanesePhoneticAnalyzerContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Management.Deployment.Preview.DeploymentPreviewContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Management.Orchestration.OrchestrationContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Management.Workplace.WorkplaceSettingsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Media.Capture.AppCaptureContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Media.Capture.CameraCaptureUIContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Media.Devices.CallControlContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Media.MediaControlContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Media.Playlists.PlaylistsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Media.Protection.ProtectionRenewalContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Networking.NetworkOperators.LegacyNetworkOperatorsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Networking.Sockets.ControlChannelTriggerContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Perception.Automation.Core.PerceptionAutomationCoreContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Security.EnterpriseData.EnterpriseDataContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Security.ExchangeActiveSyncProvisioning.EasContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Services.Maps.GuidanceContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Services.Maps.LocalSearchContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.Profile.SystemManufacturers.SystemManufacturersContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.Profile.ProfileRetailInfoContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.UserProfile.UserProfileContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.UserProfile.UserProfileLockScreenContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.UI.ApplicationSettings.ApplicationsSettingsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.UI.Core.AnimationMetrics.AnimationMetricsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.UI.Core.CoreWindowDialogsContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.UI.Xaml.Hosting.HostingContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Web.Http.Diagnostics.HttpDiagnosticsContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.System.SystemManagementContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.Calls.CallsPhoneContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.ApplicationModel.CommunicationBlocking.CommunicationBlockingContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.SmartCards.SmartCardBackgroundTriggerContract\2.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Devices.SmartCards.SmartCardEmulatorContract\3.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Embedded.DeviceLockdown.DeviceLockdownContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Networking.NetworkOperators.NetworkOperatorsFdnContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Phone.PhoneContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.Phone.StartScreen.DualSimTileContract\1.0.0.0" "-additionalAssemblyPath=C:\Program Files (x86)\Windows Kits\10\References\Windows.UI.WebUI.Core.WebUICommandBarContract\1.0.0.0" "-additionalAssemblyPath=Temp\StagingArea\Data\Managed".
    Symbols will be read from Temp\StagingArea\Data\Managed\UnityEngine.CoreModule.pdb
    Symbols will be read from Temp\StagingArea\Data\Managed\BestHTTP.pdb
    Weaving assembly C:\dev\git\ART.Hololens\Temp\StagingArea\Data\Managed\BestHTTP.dll
    System.InvalidOperationException: Operation is not valid due to the current state of the object.
    at Mono.Cecil.ModuleDefinition.ReadSymbols(ISymbolReader reader)
    at Mono.Cecil.ModuleReader.ReadSymbols(ModuleDefinition module, ReaderParameters parameters)
    at Mono.Cecil.ModuleReader.CreateModule(Image image, ReaderParameters parameters)
    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
    at usw.Weaver.WeaveAssembly(String assemblyPath, AssemblyDefinition unityEngineAssemblyDefinition, ReaderParameters readerParameters) in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Weaver.cs:line 95
    at usw.Weaver.Weave() in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Weaver.cs:line 50
    at usw.Program.RunProgram(ConversionOptions options) in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Program.cs:line 33
    at usw.Program.Main(String[] args) in C:\buildslave\unity\build\Tools\SerializationWeaver\sw\Program.cs:line 14

    PostProcessWinRT.RunSerializationWeaver () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:810)
    PostProcessWinRT.Process () (at C:/buildslave/unity/build/PlatformDependent/MetroPlayer/Extensions/Managed/PostProcessWinRT.cs:203)


    We are using Basic version.

    Before we switched to the latest Unity and were using Unity 5.6.2f1 everything worked well and even more I can say that it was working well on Hololens but right now we got just this problem with building it.

    Any idea how to solve this?
     
  41. Christian_G

    Christian_G

    Joined:
    Aug 22, 2017
    Posts:
    3
    Same problem here.. I get 4 errors with the same version of unity 2017.3.1f1:
     

    Attached Files:

  42. TailKitty

    TailKitty

    Joined:
    Nov 23, 2016
    Posts:
    6
    The fourth error in your list regarding Delegate could be solved if you will update your BestHtttp up to the latest one (We got the same error also before the update) but this will not solve the rest problems (at least for us..).
     
  43. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @TailKitty @CG_TTC

    Sent a private mail to you with a link to a new dll that's compiled for Unity 2017.3.
     
  44. waldgeist

    waldgeist

    Joined:
    May 6, 2017
    Posts:
    56
    Hi BestHTTP,

    I thought BestHTTP would also support low-level UDP messaging. Since it didn't I am currently scratching my head about making this work. Unity's low level network transport layer does seem to use an additional hand-shaking protocol, so I tried to use .NET UDP messaging instead. But this is quite hard to set-up correctly, because it should run in a separate thread.

    Thus, I would really appreciate if BestHTTP could support UDP in a way that is easy and intuitive to use, just as the other networking options are. Are there any plans for this?

    Best, Tom
     
  45. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @waldgeist

    Hi Tom,

    Unfortunately, UDP will not be part of the plugin. HTTP is based on TCP and my plugin is for HTTP (plus protocols that built on HTTP).

    But, AFAIK Photon is using UDP, it might worth a look.
     
  46. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    193
    @BestHTTP
    I bought BestHTTP asset long time ago.
    Now I am trying to use it with JSON Web Token instead of using Cookie.
    Is there any code sample that I can follow for this?

    In addition, is it possible to run an HTTP server (and a WebSocket server) with BestHTTP in Unity?
    I may want to host a server in LAN for a multiple-player game.
    I know there is Photon for this, but I want to do this with some open source solution like BestHTTP.
     
  47. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @Dan2013

    After you generated the token, you can add to your request as a header:
    Code (CSharp):
    1. Uri uri = new Uri("https://myserver.com");
    2. var request = new HTTPRequest(uri, (req, resp) =>
    3. {
    4.     switch (req.State)
    5.     {
    6.         // The request finished without any problem.
    7.         case HTTPRequestStates.Finished:
    8.             if (resp.IsSuccess)
    9.             {
    10.                 // Log out the identifier of the request, and the response from the server.
    11.                 Debug.Log("Request Finished Successfully! Text: " + resp.DataAsText);
    12.             }
    13.             else
    14.                 Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    15.                                                 resp.StatusCode,
    16.                                                 resp.Message,
    17.                                                 resp.DataAsText));
    18.             break;
    19.  
    20.         // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    21.         case HTTPRequestStates.Error:
    22.             Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    23.             break;
    24.  
    25.         // The request aborted, initiated by the user.
    26.         case HTTPRequestStates.Aborted:
    27.             Debug.LogWarning("Request Aborted!");
    28.             break;
    29.  
    30.         // Connecting to the server is timed out.
    31.         case HTTPRequestStates.ConnectionTimedOut:
    32.             Debug.LogError("Connection Timed Out!");
    33.             break;
    34.  
    35.         // The request didn't finished in the given time.
    36.         case HTTPRequestStates.TimedOut:
    37.             Debug.LogError("Processing the request Timed Out!");
    38.             break;
    39.     }
    40. });
    41.  
    42. // Generate token:
    43. string jwToken = "......";
    44.  
    45. request.AddHeader("Authorization", "Bearer " + jwToken);
    46.  
    47. request.Send();
    "In addition, is it possible to run an HTTP server (and a WebSocket server) with BestHTTP in Unity?"
    The plugin can act as a client only.
     
  48. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    193
    @BestHTTP
    Thanks!

    I feel these nice code samples (from documentation) look pretty similar to Node.js (not like Unity coroutine style). You have another C# thread running to deal with all networking jobs, and let the developer write these closure/callback style code for application logic. Is this true?
     
  49. BestHTTP

    BestHTTP

    Joined:
    Sep 11, 2013
    Posts:
    1,383
    @Dan2013

    I don't know about threads about these, but they are just regular c# lambda expressions/anonymous functions. You could write a normal functions and pass that to the HTTPRequest's constructor:

    Code (CSharp):
    1. Uri uri = new Uri("https://myserver.com");
    2. var request = new HTTPRequest(uri, RequestHandler);
    3.  
    4. // Generate token:
    5. string jwToken = "......";
    6.  
    7. request.AddHeader("Authorization", "Bearer " + jwToken);
    8.  
    9. request.Send();
    10.  
    11.  
    12.  
    13. void RequestHandler(HTTPRequest req, HTTPResponse resp)
    14. {
    15.     switch (req.State)
    16.     {
    17.         // The request finished without any problem.
    18.         case HTTPRequestStates.Finished:
    19.             if (resp.IsSuccess)
    20.             {
    21.                 // Log out the identifier of the request, and the response from the server.
    22.                 Debug.Log("Request Finished Successfully! Text: " + resp.DataAsText);
    23.             }
    24.             else
    25.                 Debug.LogWarning(string.Format("Request Finished Successfully, but the server sent an error. Status Code: {0}-{1} Message: {2}",
    26.                                                 resp.StatusCode,
    27.                                                 resp.Message,
    28.                                                 resp.DataAsText));
    29.             break;
    30.  
    31.         // The request finished with an unexpected error. The request's Exception property may contain more info about the error.
    32.         case HTTPRequestStates.Error:
    33.             Debug.LogWarning("Request Finished with Error! " + (req.Exception != null ? (req.Exception.Message + "\n" + req.Exception.StackTrace) : "No Exception"));
    34.             break;
    35.  
    36.         // The request aborted, initiated by the user.
    37.         case HTTPRequestStates.Aborted:
    38.             Debug.LogWarning("Request Aborted!");
    39.             break;
    40.  
    41.         // Connecting to the server is timed out.
    42.         case HTTPRequestStates.ConnectionTimedOut:
    43.             Debug.LogError("Connection Timed Out!");
    44.             break;
    45.  
    46.         // The request didn't finished in the given time.
    47.         case HTTPRequestStates.TimedOut:
    48.             Debug.LogError("Processing the request Timed Out!");
    49.             break;
    50.     }
    51. }
     
  50. Dan2013

    Dan2013

    Joined:
    May 24, 2013
    Posts:
    193
    @BestHTTP
    Oh, sorry for the confusing.
    When I say "threads", I mean your overall threading design for BestHTTP, not just for the JWT examples.