Code Monkey home page Code Monkey logo

Comments (6)

anhashia avatar anhashia commented on August 21, 2024

Investigating !

from azure-iot-sdk-csharp.

olivierbloch avatar olivierbloch commented on August 21, 2024

Hi @bartoszbr 
Can you please confirm that you were successful using a device ID that doesn't contain any special character? I am asking because this shouldn't be a problem.
Another thing: are you using the received URI immediately? By default the TTL for the storage URI SAS is 1hour.
Can you share the piece of code you are using?

from azure-iot-sdk-csharp.

bartoszbr avatar bartoszbr commented on August 21, 2024

Yes I can send files to another devices where DeviceId doesn't have any special character. I checked it also on another Azure account with another subscription and there was the same.
In every cases I use standard, default Azure Storage - I just connected it with my IoT Hub.

Initialization of DeviceClient object:
deviceClient = DeviceClient.Create(iotHubUri, new DeviceAuthenticationWithRegistrySymmetricKey(deviceName, deviceKey));

Method to handle Click event and call UploadToBlobAsync:

  private async void sendFileButton_Click(object sender, EventArgs e)
        {
            if (ControlsHelper.IsComboBoxSelected(deviceIdComboBox, "Device ID") == false)
                return;

            var openFileDialog = new OpenFileDialog();
            var result = openFileDialog.ShowDialog();

            if (result != DialogResult.OK)
                return;

            using (var fileStream = openFileDialog.OpenFile())
            {
                var watch = System.Diagnostics.Stopwatch.StartNew();
                try
                {
                    await deviceClient.UploadToBlobAsync(openFileDialog.SafeFileName, fileStream);
                }
                catch (Exception ex)
                {
                    LogError("Exception occurred during sending file", ex);
                    watch.Stop();
                    return;
                }

                watch.Stop();
                var text = $"DeviceID: {deviceIdComboBox.SelectedItem} File {openFileDialog.SafeFileName} was sent in {watch.ElapsedMilliseconds}ms";
                LogInformation(text, sentMessagesRrichTextBox);
            }
        }

from azure-iot-sdk-csharp.

anhashia avatar anhashia commented on August 21, 2024

Hi @bartoszbr
I was able to locally reproduce the issue using # symbol in device ID . The issue is specific to C# client SDK and doesn't happen with C Azure IoT SDK.

The issue happens when following call is made
https://github.com/Azure/azure-iot-sdk-csharp/blob/master/device/Microsoft.Azure.Devices.Client/Transport/HttpTransportHandler.cs#L230
When CloudBlockBlob object is created it omits special character # in StorageURI along with string after it. That is why UploadFromStreamAsync call fails.

Further investigation is going on to resolve this.

from azure-iot-sdk-csharp.

anhashia avatar anhashia commented on August 21, 2024

Hi @bartoszbr
Fix for this issue has been merged 2366f03 into master

from azure-iot-sdk-csharp.

tameraw avatar tameraw commented on August 21, 2024

This is now in the latest release. Closing.

from azure-iot-sdk-csharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.