this is my first experience with network code.
I'm developing a small mobile game and I'm using (C#, Visual Studio, Unity) for this. ((I beg you, let's do without comments about unity...))
I need to start debugging my game, but renting a server for these purposes is not financially profitable.
I understand that you can use localhost, but I would like to test the application in conditions that are as close to reality as possible.
My Internet provider does not allow me to open a port and use my computer as a server.
We thought that it might be possible to configure the server to work over a local Hamachi network, but we could not find information on this topic.
We tried to directly specify the IP from Hamachi, the server was successfully launched, but we couldn’t connect to it
I would like to know if it is possible to set up a network connection via kamachi? Are there any options for how I could run the server on my computer in other ways?
Startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using SignalRtest.Hubs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace SignalRtest
{
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddSignalR();
}
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
app.UseHsts();
}
// app.UseCors("CorsPolicy");
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
// app.MapHub<MyHubs>("/myhubs");
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
endpoints.MapHub<myhubs>("/myhubs");
});
}
}
}
launchSettings.json
We tried to indicate the IP of both my computer and the Hamachi network. We also tried to specify different ports.
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:52131",
"sslPort": 44378
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"SignalRtest": {
"commandName": "Project",
"launchBrowser": true,
"applicationUrl": "https://25.35.XXX.XX:12975;http://25.35.XXX.XX:32976",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
CLIENT
public void HUB_CONNECTED()
{
HubConnections = new HubConnectionBuilder()
.WithUrl("https://25.35.XXX.XX:12975/myhubs")
.WithAutomaticReconnect()
.Build();
}
I should note that if you specify the default value (https://localhost:5001;http://localhost:5000) then everything works fine. But as I said earlier, I wanted to test the game on different devices.
You can answer me in English and Russian, Thank you