How can i determine a private and public IP Address.
For ex. I have bin given an IP address 190.168.1.254 is this a private or public IP address.
Please explain in the comments below.
this is the private ip address ranges:
10.0.0.0 – 10.255.255.255,
172.16.0.0 – 172.31.255.255,
192.168.0.0 – 192.168.255.255
if any ip isn't in this ranges so it's a public ip
190.168.1.254 is a public ip because it starts with 190 and there's no private ip range start with 190
Related
First of all, excuse my English, it's very bad. I am using MassTransit with Azure Service Bus for asynchronous communication between microservices. I have some doubts about the default configuration of masstransit together with azure service bus, but I have not been able to clarify them in the documentation. These doubts are the following:
Is there a way to set a default TTL for all queues and topics? And a size for the queues and topics? The documentation specifies that the TTL and the size of the queues can be adjusted when the receiver is connected / created, but on the other hand, regarding the topics, it is specified how to adjust the TTL if the consumer connects to a specific topic, however in this case our consumers do not subscribe to a specific topic, but simply to a messageType, and Masstransit does the rest (creates the topic, the subscriber and forwards the message from the subscriber to the consumer's queue).
On the other hand, what are the default values of PrefetchCount and MaxConcurrentCalls?
And some optimal values to obtain the highest performance considering that consumers have horizontal scaling (competing consumer)? From what I have read in other questions, the PrefetchCount and MaxConcurrentCalls values must be close to each other to optimize performance, is that correct?
Thank you very much.
Regards
The defaults for all Azure Service Bus entities are in this file and can be adjusted prior to bus creation.
The defaults include (edited):
namespace MassTransit.Azure.ServiceBus.Core
{
public static class Defaults
{
public static TimeSpan LockDuration = TimeSpan.FromMinutes(5);
public static TimeSpan DefaultMessageTimeToLive = TimeSpan.FromDays(365 + 1);
public static TimeSpan BasicMessageTimeToLive = TimeSpan.FromDays(14);
public static TimeSpan AutoDeleteOnIdle => TimeSpan.FromDays(427);
public static TimeSpan TemporaryAutoDeleteOnIdle => TimeSpan.FromMinutes(5);
public static TimeSpan MaxAutoRenewDuration => TimeSpan.FromMinutes(5);
public static TimeSpan MessageWaitTimeout => TimeSpan.FromSeconds(10);
public static TimeSpan ShutdownTimeout { get; set; } = TimeSpan.FromMilliseconds(100);
public static int MaxConcurrentCalls => Math.Max(Environment.ProcessorCount, 8);
public static int PrefetchCount => Math.Max(MaxConcurrentCalls, 32);
}
}
As for optimizing the PrefetchCount/MaxConcurrentCalls settings, they should typically be matched for competing consumer with multiple instances to distribute the load.
I have an extremely basic API set up on my IIS. I'm doing nothing with the code yet:
public class RESTAPIController : ApiController
{
// GET: api/RESTAPI
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET: api/RESTAPI/5
public string Get(int id)
{
return "value";
}
// POST: api/RESTAPI
public void Post([FromBody]string value)
{
}
// PUT: api/RESTAPI/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE: api/RESTAPI/5
public void Delete(int id)
{
}
}
What I need to do is be able to POST/GET to this API from another computer on the same network. I can POST/GET/etc. on my own computer using the YARC Google Chrome extension. If I am debugging the API from Visual Studio, the breakpoint hits letting me know that it's working, I also get the 200 response back.
I'd like to be able to POST/GET to this API from another computer that lives on the same network. I always get a connection timeout error. The URL seen in the YARC app photo uses http://172.16.1.132:100/RestAPI/api/RESTAPI where "172.16.1.132" is my PC's ethernet port ip address for the port I am connected to. ":100" is the port that I have bound in IIS, ":80" could also be used. "RestAPI" is the name of the API that I am trying to call and "api/RESTAPI" is how to call the POST/GET method.
I've tried:
Completely disabling my firewall and Windows Defender;
Disabling the firewall on my router;
various configurations of the URL (different ports/authentication types/etc).
I'm very new to web apps and networking and I'm not even sure if what I am trying to do is possible. Any help is greatly appreciated. Thanks in advance!
Use iisexpress-proxy - A simple local proxy for accessing IIS Express from remote machines.
Open command prompt as administrator and run
npm install -g iisexpress-proxy
then
iisexpress-proxy 100 to 81 (100 - localPort and 81 proxyPort)
Access the API using this address on the other PC http://172.16.1.132:81/RestAPI/api/RESTAPI
Note: instead of 81 any other unused port can also be taken.
I'm using a postcode lookup service provided online using a class they provide.
The returned information is a list of addresses in the format
<XmlRootAttribute("Addresses")> _
Public Class Addresses
<XmlElementAttribute("Address")> _
Public Address As List(Of Address)
End Class
where Address is
Public Class Address
Public organisation As String
Public premise As String
Public dependentstreet As String
Public street As String
Public doubledependentlocality As String
Public dependentlocality As String
Public posttown As String
Public county As String
Public postcode As String
Public summaryline As String
Public Overrides Function ToString() As String
Return summaryline
End Function
End Class
The summaryline property returns a comma separated list of the Address class (e.g)
Fox Road, Framingham Pigot, Norwich, Norfolk, NR14 7PZ
I'm using this list of returned addresses to populate a dropdownlist, which will then split up the selected address into "Address 1", "Address 2", "Town" etc.
In the code example provided they are using a Windows Form and populate a Combobox and the line that splits the comma seperated address into an Address class is this line
Dim address As Address = DirectCast(addresses_ComboBox.SelectedItem, Address)
organisation_TextBox.Text = address.organisation
premise_TextBox.Text = address.premise
dependentStreet_TextBox.Text = address.dependentstreet
street_TextBox.Text = address.street
doubleDependentLocality_TextBox.Text = address.doubledependentlocality
locality_TextBox.Text = address.dependentlocality
town_TextBox.Text = address.posttown
county_TextBox.Text = address.county
postcode_TextBox.Text = address.postcode
Is there a way for me to convert that top line but using dropdownlist.SelectedValue instead of addresses_ComboBox.SelectedItem
I can split the string into an array but not all addresses have all of the Address class properties returned. Some addresses may not have a Premise for example so I can't convert the comma separated address back into the Address class perfectly into each property.
Thanks for looking!
I want to broadcast message using SignalR from server to all clients at particular server time. This broadcast message should be automatic where all clients keep listening to server method and once we reach the scheduled time on server, server should broadcast the message.
But I don't find a way to this. I was successful by invoking from a client and broadcasting it to all clients but not automatically.
How this can be achieved.
First you need some sort of hub:
public class MyHub : Hub {}
You then can connect to this hub with clients or whatever you want to do. Then you need some type of looping class that sends to your hub (you could also do this within the hub as a static timer but we'll do this as a separate class).
public class Looper
{
public Timer Interval
public Looper(TimeSpan interval)
{
Interval = new Timer(Loop, null, TimeSpan.Zero, interval);
}
private static void Loop(object state)
{
GlobalHost.ConnectionManager.GetHubContext<ChatHub>().Clients.All.executeYourMethod();
}
}
Now we need to instantiate this class somewhere, we'll do that inside our hub as a static:
public class MyHub : Hub
{
public static Looper MyInterval = new Looper(TimeSpan.FromSeconds(1)); // Send every 1 second
}
Hope this helps!
You can just add a timer to your hub class and broadcast to each client at the required intervals.
Hello guys I am trying to retrieve my ip address using the following c# code and all I got is the 127.0.0.0. IP address. I need to display my IPA like which would display on google searh when I type what is my ip address.
Can you help? Thank you so much
HttpContext.Current.Request.ServerVariables("REMOTE_ADDR")
Request.ServerVariables("REMOTE_HOST")
Request.UserHostAddress()
Request.UserHostName()
string strHostName = System.Net.Dns.GetHostName();
string clientIPAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
I've tried this as well but it throw an exception "only ipv4 is supported"
You can also try the below:
using System;
using System.Web;
namespace WebApplication1
{
public class Global : HttpApplication
{
protected void Application_BeginRequest(object sender, EventArgs e)
{
// Get request.
HttpRequest request = base.Request;
// Get UserHostAddress property.
string address = request.UserHostAddress;
// Write to response.
base.Response.Write(address);
// Done.
base.CompleteRequest();
}
}
}