Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

StackOverflow Point

StackOverflow Point Navigation

  • Web Stories
  • Badges
  • Tags
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Web Stories
  • Badges
  • Tags
Home/ Questions/Q 4069
Alex Hales
  • 0
Alex HalesTeacher
Asked: June 3, 20222022-06-03T11:14:08+00:00 2022-06-03T11:14:08+00:00

c# – Microsoft.Graph.ServiceException—> System.Net.Sockets.SocketException. while getting TransitiveMemberOf

  • 0

[ad_1]

I’m seen System.Net.Sockets.SocketException: Connection reset by peer error doing the call to retrieve groups using TransitiveMemberOf method from Microsoft.Graph.dll.

 public async Task<List<AdGroup>> GetAllGroupsByUserId(string userId, CancellationToken token)
    {
        _client = GraphConnection.GetGraphClient(_config);
        var memberships = new List<AdGroup>();
        try
        {
            IUserTransitiveMemberOfCollectionWithReferencesRequest? next = null;
            do
            {
                IUserTransitiveMemberOfCollectionWithReferencesPage data;
                if (next == null)
                {
                    var id = Guid.NewGuid().ToString();
                    var options = new List<Option>()
                    {
                        new QueryOption("$top", "999"),
                        new HeaderOption("client-request-id", id)
                    };

                    data = await _client.Users[userId].TransitiveMemberOf.Request(options).Select("id,displayName").GetAsync(token);
                }
                else
                {
                    data = await next.GetAsync(token);
                }

                next = data.NextPageRequest;
                if (data.CurrentPage.Count == 0)
                    break;

                var foundGroups = data.CurrentPage
                    .Select(i =>
                    {

                        if (i is Group group)
                            return new AdGroup()
                            {
                                Id = group.Id,
                                Name = string.IsNullOrWhiteSpace(group.DisplayName) ? group.AdditionalData?["displayName"].ToString() ?? "" : group.DisplayName
                            };
                        if (i is DirectoryRole role)
                            return new AdGroup()
                            {
                                Id = role.Id,
                                Name = string.IsNullOrWhiteSpace(role.DisplayName) ? role.AdditionalData?["displayName"].ToString() ?? "" : role.DisplayName
                            };
                        return null;
                    })
                    .Where(g => g != null && Constants.CONTAINS_LIST.Any(c => g.Name.Contains(c, StringComparison.InvariantCultureIgnoreCase)));
                    
                if (foundGroups != null)
                    memberships.AddRange(foundGroups);

            } while (next != null);
        }
        catch (Exception e)
        {
            _logger.LogError(e, "GetAllGroupsByUserId error");
        }
        return memberships;
    }

I tried to run the code from Azure VM ( I have Linux OS there) as well as from my local machine (Windows OS). Now I’m checking the load of VM because the code is running in threads and thinking about what can be wrong.

I’ve also created a ticken in Azure Portal and I have the following answer from the Microsoft:

This error is not coming from Microsoft Graph rather from your clients
socket (otherwise meaning a network error)

For these errors, you must start with your networking team to
investigate. There could be a number of networking reasons i.e. your
Firewall, Proxy, Loadbalancer, network bandwidth throttling.

That answer didn’t help me a lot, but I’m trying to investigate futher.

I will appreciate any help, thanks

[ad_2]

  • 0 0 Answers
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report
Leave an answer

Leave an answer
Cancel reply

Browse

Sidebar

Ask A Question

Related Questions

  • xcode - Can you build dynamic libraries for iOS and ...

    • 0 Answers
  • bash - How to check if a process id (PID) ...

    • 8087 Answers
  • database - Oracle: Changing VARCHAR2 column to CLOB

    • 1871 Answers
  • What's the difference between HEAD, working tree and index, in ...

    • 1957 Answers
  • Amazon EC2 Free tier - how many instances can I ...

    • 0 Answers

Stats

  • Questions : 43k

Subscribe

Login

Forgot Password?

Footer

Follow

© 2022 Stackoverflow Point. All Rights Reserved.

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.